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
7d44435d
Commit
7d44435d
authored
Jul 06, 2017
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🔨
适应 Latke 框架调整
parent
15618f0f
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
96 additions
and
181 deletions
+96
-181
src/main/java/org/b3log/solo/event/rhythm/ArticleSender.java
src/main/java/org/b3log/solo/event/rhythm/ArticleSender.java
+2
-2
src/main/java/org/b3log/solo/event/rhythm/ArticleUpdater.java
...main/java/org/b3log/solo/event/rhythm/ArticleUpdater.java
+2
-2
src/main/java/org/b3log/solo/event/symphony/CommentSender.java
...ain/java/org/b3log/solo/event/symphony/CommentSender.java
+5
-6
src/main/java/org/b3log/solo/plugin/broadcast/ChanceProcessor.java
...java/org/b3log/solo/plugin/broadcast/ChanceProcessor.java
+25
-45
src/main/java/org/b3log/solo/processor/BlogProcessor.java
src/main/java/org/b3log/solo/processor/BlogProcessor.java
+11
-34
src/main/java/org/b3log/solo/processor/CaptchaProcessor.java
src/main/java/org/b3log/solo/processor/CaptchaProcessor.java
+11
-24
src/main/java/org/b3log/solo/processor/console/AdminConsole.java
...n/java/org/b3log/solo/processor/console/AdminConsole.java
+4
-17
src/main/java/org/b3log/solo/service/InitService.java
src/main/java/org/b3log/solo/service/InitService.java
+36
-51
No files found.
src/main/java/org/b3log/solo/event/rhythm/ArticleSender.java
View file @
7d44435d
...
...
@@ -49,7 +49,7 @@ import java.util.Date;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author ArmstrongCN
* @version 1.0.2.
9, Jun 2
6, 2017
* @version 1.0.2.
10, Jul
6, 2017
* @since 0.3.1
*/
public
final
class
ArticleSender
extends
AbstractEventListener
<
JSONObject
>
{
...
...
@@ -136,7 +136,7 @@ public final class ArticleSender extends AbstractEventListener<JSONObject> {
requestJSONObject
.
put
(
"blogHost"
,
Latkes
.
getServePath
());
requestJSONObject
.
put
(
"userB3Key"
,
preference
.
optString
(
Option
.
ID_C_KEY_OF_SOLO
));
requestJSONObject
.
put
(
"clientAdminEmail"
,
preference
.
optString
(
Option
.
ID_C_ADMIN_EMAIL
));
requestJSONObject
.
put
(
"clientRuntimeEnv"
,
Latkes
.
getRuntimeEnv
().
name
()
);
requestJSONObject
.
put
(
"clientRuntimeEnv"
,
"LOCAL"
);
httpRequest
.
setPayload
(
requestJSONObject
.
toString
().
getBytes
(
"UTF-8"
));
...
...
src/main/java/org/b3log/solo/event/rhythm/ArticleUpdater.java
View file @
7d44435d
...
...
@@ -48,7 +48,7 @@ import java.util.Date;
* </p>
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
3, Jun 2
6, 2017
* @version 1.0.0.
4, Jul
6, 2017
* @since 0.6.0
*/
public
final
class
ArticleUpdater
extends
AbstractEventListener
<
JSONObject
>
{
...
...
@@ -135,7 +135,7 @@ public final class ArticleUpdater extends AbstractEventListener<JSONObject> {
requestJSONObject
.
put
(
"blogHost"
,
Latkes
.
getServerHost
()
+
":"
+
Latkes
.
getServerPort
());
requestJSONObject
.
put
(
"userB3Key"
,
preference
.
optString
(
Option
.
ID_C_KEY_OF_SOLO
));
requestJSONObject
.
put
(
"clientAdminEmail"
,
preference
.
optString
(
Option
.
ID_C_ADMIN_EMAIL
));
requestJSONObject
.
put
(
"clientRuntimeEnv"
,
Latkes
.
getRuntimeEnv
().
name
()
);
requestJSONObject
.
put
(
"clientRuntimeEnv"
,
"LOCAL"
);
httpRequest
.
setPayload
(
requestJSONObject
.
toString
().
getBytes
(
"UTF-8"
));
...
...
src/main/java/org/b3log/solo/event/symphony/CommentSender.java
View file @
7d44435d
...
...
@@ -45,7 +45,7 @@ import java.net.URL;
* This listener is responsible for sending comment to B3log Symphony.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
4, Nov 20, 2015
* @version 1.0.0.
5, Jul 6, 2017
* @since 0.5.5
*/
public
final
class
CommentSender
extends
AbstractEventListener
<
JSONObject
>
{
...
...
@@ -53,7 +53,7 @@ public final class CommentSender extends AbstractEventListener<JSONObject> {
/**
* Logger.
*/
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
CommentSender
.
class
.
getName
()
);
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
CommentSender
.
class
);
/**
* URL fetch service.
...
...
@@ -87,7 +87,6 @@ public final class CommentSender extends AbstractEventListener<JSONObject> {
final
PreferenceQueryService
preferenceQueryService
=
beanManager
.
getReference
(
PreferenceQueryService
.
class
);
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
if
(
null
==
preference
)
{
throw
new
EventException
(
"Not found preference"
);
}
...
...
@@ -113,7 +112,7 @@ public final class CommentSender extends AbstractEventListener<JSONObject> {
requestJSONObject
.
put
(
Comment
.
COMMENT
,
comment
);
requestJSONObject
.
put
(
"clientVersion"
,
SoloServletListener
.
VERSION
);
requestJSONObject
.
put
(
"clientRuntimeEnv"
,
Latkes
.
getRuntimeEnv
().
name
()
);
requestJSONObject
.
put
(
"clientRuntimeEnv"
,
"LOCAL"
);
requestJSONObject
.
put
(
"clientName"
,
"B3log Solo"
);
requestJSONObject
.
put
(
"clientHost"
,
Latkes
.
getServerHost
()
+
":"
+
Latkes
.
getServerPort
());
requestJSONObject
.
put
(
"clientAdminEmail"
,
preference
.
optString
(
Option
.
ID_C_ADMIN_EMAIL
));
...
...
src/main/java/org/b3log/solo/plugin/broadcast/ChanceProcessor.java
View file @
7d44435d
...
...
@@ -52,7 +52,7 @@ import java.util.concurrent.Future;
* Broadcast chance processor.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.1
0, Nov 20, 2015
* @version 1.0.0.1
1, Jul 6, 2017
* @since 0.6.0
*/
@RequestProcessor
...
...
@@ -61,7 +61,7 @@ public class ChanceProcessor {
/**
* Logger.
*/
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
ChanceProcessor
.
class
.
getName
()
);
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
ChanceProcessor
.
class
);
/**
* Option management service.
...
...
@@ -108,7 +108,6 @@ public class ChanceProcessor {
/**
* Adds a broadcast chance to option repository.
*
* <p>
* Renders the response with a json object, for example,
* <pre>
...
...
@@ -128,18 +127,14 @@ public class ChanceProcessor {
public
void
addChance
(
final
HTTPRequestContext
context
,
final
HttpServletRequest
request
,
final
HttpServletResponse
response
)
throws
Exception
{
final
JSONRenderer
renderer
=
new
JSONRenderer
();
context
.
setRenderer
(
renderer
);
final
JSONObject
ret
=
new
JSONObject
();
renderer
.
setJSONObject
(
ret
);
try
{
// TODO: verify b3 key
final
String
time
=
request
.
getParameter
(
"time"
);
if
(
Strings
.
isEmptyOrNull
(
time
))
{
ret
.
put
(
Keys
.
STATUS_CODE
,
false
);
...
...
@@ -147,9 +142,7 @@ public class ChanceProcessor {
}
final
long
expirationTime
=
Long
.
valueOf
(
time
);
final
JSONObject
option
=
new
JSONObject
();
option
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_BROADCAST_CHANCE_EXPIRATION_TIME
);
option
.
put
(
Option
.
OPTION_VALUE
,
expirationTime
);
option
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_BROADCAST
);
...
...
@@ -171,11 +164,9 @@ public class ChanceProcessor {
/**
* Dose the client has a broadcast chance.
*
* <p>
* If the request come from a user not administrator, consider it is no broadcast chance.
* </p>
*
* <p>
* Renders the response with a json object, for example,
* <pre>
...
...
@@ -201,11 +192,8 @@ public class ChanceProcessor {
}
final
JSONRenderer
renderer
=
new
JSONRenderer
();
context
.
setRenderer
(
renderer
);
final
JSONObject
ret
=
new
JSONObject
();
renderer
.
setJSONObject
(
ret
);
if
(!
userQueryService
.
isAdminLoggedIn
(
request
))
{
...
...
@@ -217,7 +205,6 @@ public class ChanceProcessor {
try
{
final
JSONObject
option
=
optionQueryService
.
getOptionById
(
Option
.
ID_C_BROADCAST_CHANCE_EXPIRATION_TIME
);
if
(
null
==
option
)
{
ret
.
put
(
Option
.
ID_C_BROADCAST_CHANCE_EXPIRATION_TIME
,
0L
);
ret
.
put
(
Keys
.
STATUS_CODE
,
false
);
...
...
@@ -238,7 +225,6 @@ public class ChanceProcessor {
/**
* Submits a broadcast.
*
* <p>
* Renders the response with a json object, for example,
* <pre>
...
...
@@ -251,7 +237,6 @@ public class ChanceProcessor {
*
* @param context the specified http request context
* @param request the specified http servlet request, for example,
* <pre>
* {
* "broadcast": {
* "title": "",
...
...
@@ -259,7 +244,6 @@ public class ChanceProcessor {
* "link": "" // optional
* }
* }
* </pre>
* @param response the specified http servlet response
* @throws Exception
*/
...
...
@@ -273,11 +257,8 @@ public class ChanceProcessor {
}
final
JSONRenderer
renderer
=
new
JSONRenderer
();
context
.
setRenderer
(
renderer
);
final
JSONObject
ret
=
new
JSONObject
();
renderer
.
setJSONObject
(
ret
);
try
{
...
...
@@ -290,7 +271,7 @@ public class ChanceProcessor {
final
String
clientName
=
"B3log Solo"
;
final
String
clientVersion
=
SoloServletListener
.
VERSION
;
final
String
clientTitle
=
preference
.
getString
(
Option
.
ID_C_BLOG_TITLE
);
final
String
clientRuntimeEnv
=
Latkes
.
getRuntimeEnv
().
name
()
;
final
String
clientRuntimeEnv
=
"LOCAL"
;
final
JSONObject
broadcastRequest
=
new
JSONObject
();
...
...
@@ -309,8 +290,7 @@ public class ChanceProcessor {
httpRequest
.
setRequestMethod
(
HTTPRequestMethod
.
POST
);
httpRequest
.
setPayload
(
broadcastRequest
.
toString
().
getBytes
(
"UTF-8"
));
@SuppressWarnings
(
"unchecked"
)
final
Future
<
HTTPResponse
>
future
=
(
Future
<
HTTPResponse
>)
urlFetchService
.
fetchAsync
(
httpRequest
);
@SuppressWarnings
(
"unchecked"
)
final
Future
<
HTTPResponse
>
future
=
(
Future
<
HTTPResponse
>)
urlFetchService
.
fetchAsync
(
httpRequest
);
final
HTTPResponse
result
=
future
.
get
();
if
(
HttpServletResponse
.
SC_OK
==
result
.
getResponseCode
())
{
...
...
src/main/java/org/b3log/solo/processor/BlogProcessor.java
View file @
7d44435d
...
...
@@ -17,7 +17,6 @@ package org.b3log.solo.processor;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.RuntimeEnv
;
import
org.b3log.latke.ioc.inject.Inject
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.model.Pagination
;
...
...
@@ -52,7 +51,7 @@ import java.util.Set;
* Blog processor.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.3.0.
4, Dec 17, 2015
* @version 1.3.0.
5, Jul 6, 2017
* @since 0.4.6
*/
@RequestProcessor
...
...
@@ -61,7 +60,7 @@ public class BlogProcessor {
/**
* Logger.
*/
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
BlogProcessor
.
class
.
getName
()
);
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
BlogProcessor
.
class
);
/**
* Article query service.
...
...
@@ -100,7 +99,6 @@ public class BlogProcessor {
/**
* Gets blog information.
*
* <ul>
* <li>Time of the recent updated article</li>
* <li>Article count</li>
...
...
@@ -119,11 +117,8 @@ public class BlogProcessor {
@RequestProcessing
(
value
=
"/blog/info"
,
method
=
HTTPRequestMethod
.
GET
)
public
void
getBlogInfo
(
final
HTTPRequestContext
context
)
throws
Exception
{
final
JSONRenderer
renderer
=
new
JSONRenderer
();
context
.
setRenderer
(
renderer
);
final
JSONObject
jsonObject
=
new
JSONObject
();
renderer
.
setJSONObject
(
jsonObject
);
jsonObject
.
put
(
"recentArticleTime"
,
articleQueryService
.
getRecentArticleTime
());
...
...
@@ -137,13 +132,8 @@ public class BlogProcessor {
jsonObject
.
put
(
"version"
,
SoloServletListener
.
VERSION
);
jsonObject
.
put
(
"locale"
,
Latkes
.
getLocale
());
jsonObject
.
put
(
"runtimeMode"
,
Latkes
.
getRuntimeMode
());
final
RuntimeEnv
runtimeEnv
=
Latkes
.
getRuntimeEnv
();
jsonObject
.
put
(
"runtimeEnv"
,
runtimeEnv
);
if
(
RuntimeEnv
.
LOCAL
==
runtimeEnv
)
{
jsonObject
.
put
(
"runtimeDatabase"
,
Latkes
.
getRuntimeDatabase
());
}
}
/**
* Sync user to https://hacpai.com.
...
...
@@ -154,11 +144,8 @@ public class BlogProcessor {
@RequestProcessing
(
value
=
"/blog/symphony/user"
,
method
=
HTTPRequestMethod
.
GET
)
public
void
syncUser
(
final
HTTPRequestContext
context
)
throws
Exception
{
final
JSONRenderer
renderer
=
new
JSONRenderer
();
context
.
setRenderer
(
renderer
);
final
JSONObject
jsonObject
=
new
JSONObject
();
renderer
.
setJSONObject
(
jsonObject
);
if
(
Latkes
.
getServePath
().
contains
(
"localhost"
))
{
...
...
@@ -166,19 +153,16 @@ public class BlogProcessor {
}
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
if
(
null
==
preference
)
{
return
;
// not init yet
}
final
HTTPRequest
httpRequest
=
new
HTTPRequest
();
httpRequest
.
setURL
(
new
URL
(
SoloServletListener
.
B3LOG_SYMPHONY_SERVE_PATH
+
"/apis/user"
));
httpRequest
.
setRequestMethod
(
HTTPRequestMethod
.
POST
);
final
JSONObject
requestJSONObject
=
new
JSONObject
();
final
JSONObject
admin
=
userQueryService
.
getAdmin
();
requestJSONObject
.
put
(
User
.
USER_NAME
,
admin
.
getString
(
User
.
USER_NAME
));
requestJSONObject
.
put
(
User
.
USER_EMAIL
,
admin
.
getString
(
User
.
USER_EMAIL
));
requestJSONObject
.
put
(
User
.
USER_PASSWORD
,
admin
.
getString
(
User
.
USER_PASSWORD
));
...
...
@@ -192,7 +176,7 @@ public class BlogProcessor {
/**
* Gets tags of all articles.
*
*
<p>
* <pre>
* {
* "data": [
...
...
@@ -202,6 +186,7 @@ public class BlogProcessor {
* ]
* }
* </pre>
* </p>
*
* @param context the specified context
* @param request the specified HTTP servlet request
...
...
@@ -212,7 +197,6 @@ public class BlogProcessor {
public
void
getArticlesTags
(
final
HTTPRequestContext
context
,
final
HttpServletRequest
request
,
final
HttpServletResponse
response
)
throws
Exception
{
final
String
pwd
=
request
.
getParameter
(
"pwd"
);
if
(
Strings
.
isEmptyOrNull
(
pwd
))
{
response
.
sendError
(
HttpServletResponse
.
SC_FORBIDDEN
);
...
...
@@ -220,7 +204,6 @@ public class BlogProcessor {
}
final
JSONObject
admin
=
userQueryService
.
getAdmin
();
if
(!
MD5
.
hash
(
pwd
).
equals
(
admin
.
getString
(
User
.
USER_PASSWORD
)))
{
response
.
sendError
(
HttpServletResponse
.
SC_FORBIDDEN
);
...
...
@@ -228,7 +211,6 @@ public class BlogProcessor {
}
final
JSONObject
requestJSONObject
=
new
JSONObject
();
requestJSONObject
.
put
(
Pagination
.
PAGINATION_CURRENT_PAGE_NUM
,
1
);
requestJSONObject
.
put
(
Pagination
.
PAGINATION_PAGE_SIZE
,
Integer
.
MAX_VALUE
);
requestJSONObject
.
put
(
Pagination
.
PAGINATION_WINDOW_SIZE
,
Integer
.
MAX_VALUE
);
...
...
@@ -250,15 +232,11 @@ public class BlogProcessor {
final
JSONArray
articles
=
result
.
optJSONArray
(
Article
.
ARTICLES
);
final
JSONRenderer
renderer
=
new
JSONRenderer
();
context
.
setRenderer
(
renderer
);
final
JSONObject
ret
=
new
JSONObject
();
renderer
.
setJSONObject
(
ret
);
final
JSONArray
data
=
new
JSONArray
();
ret
.
put
(
"data"
,
data
);
for
(
int
i
=
0
;
i
<
articles
.
length
();
i
++)
{
...
...
@@ -266,14 +244,12 @@ public class BlogProcessor {
final
String
tagString
=
article
.
optString
(
Article
.
ARTICLE_TAGS_REF
);
final
JSONArray
tagArray
=
new
JSONArray
();
data
.
put
(
tagArray
);
final
String
[]
tags
=
tagString
.
split
(
","
);
for
(
final
String
tag
:
tags
)
{
final
String
trim
=
tag
.
trim
();
if
(!
Strings
.
isEmptyOrNull
(
trim
))
{
tagArray
.
put
(
tag
);
}
...
...
@@ -283,12 +259,13 @@ public class BlogProcessor {
/**
* Gets interest tags (top 10 and bottom 10).
*
*
<p>
* <pre>
* {
* "data": ["tag1", "tag2", ....]
* }
* </pre>
* </p>
*
* @param context the specified context
* @param request the specified HTTP servlet request
...
...
src/main/java/org/b3log/solo/processor/CaptchaProcessor.java
View file @
7d44435d
...
...
@@ -17,8 +17,6 @@ package org.b3log.solo.processor;
import
org.apache.commons.io.IOUtils
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.RuntimeEnv
;
import
org.b3log.latke.image.Image
;
import
org.b3log.latke.image.ImageService
;
import
org.b3log.latke.image.ImageServiceFactory
;
...
...
@@ -35,7 +33,6 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
import
java.io.*
;
import
java.net.URL
;
import
java.util.Enumeration
;
import
java.util.Random
;
import
java.util.zip.ZipEntry
;
...
...
@@ -44,14 +41,12 @@ import java.util.zip.ZipFile;
/**
* Captcha processor.
*
* <p>
* Checkout <a href="http://toy-code.googlecode.com/svn/trunk/CaptchaGenerator">
* the sample captcha generator</a> for more details.
* Checkout <a href="http://toy-code.googlecode.com/svn/trunk/CaptchaGenerator"> the sample captcha generator</a> for more details.
* </p>
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.
4, Oct 31, 2015
* @version 1.1.0.
5, Jul 6, 2017
* @since 0.3.1
*/
@RequestProcessor
...
...
@@ -60,7 +55,7 @@ public class CaptchaProcessor {
/**
* Logger.
*/
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
CaptchaProcessor
.
class
.
getName
()
);
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
CaptchaProcessor
.
class
);
/**
* Images service.
...
...
@@ -132,23 +127,15 @@ public class CaptchaProcessor {
try
{
captchas
=
new
Image
[
CAPTCHA_COUNT
];
ZipFile
zipFile
;
if
(
RuntimeEnv
.
LOCAL
==
Latkes
.
getRuntimeEnv
())
{
final
InputStream
inputStream
=
SoloServletListener
.
class
.
getClassLoader
().
getResourceAsStream
(
"captcha_static.zip"
);
final
File
file
=
File
.
createTempFile
(
"b3log_captcha_static"
,
null
);
final
OutputStream
outputStream
=
new
FileOutputStream
(
file
);
IOUtils
.
copy
(
inputStream
,
outputStream
);
zipFile
=
new
ZipFile
(
file
);
final
ZipFile
zipFile
=
new
ZipFile
(
file
);
IOUtils
.
closeQuietly
(
inputStream
);
IOUtils
.
closeQuietly
(
outputStream
);
}
else
{
final
URL
captchaURL
=
SoloServletListener
.
class
.
getClassLoader
().
getResource
(
"captcha_static.zip"
);
zipFile
=
new
ZipFile
(
captchaURL
.
getFile
());
}
final
Enumeration
<?
extends
ZipEntry
>
entries
=
zipFile
.
entries
();
...
...
src/main/java/org/b3log/solo/processor/console/AdminConsole.java
View file @
7d44435d
...
...
@@ -70,7 +70,7 @@ import java.util.*;
* Admin console render processing.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.5.2.1
1, Jun 18
, 2017
* @version 1.5.2.1
2, Jul 6
, 2017
* @since 0.4.1
*/
@RequestProcessor
...
...
@@ -117,16 +117,6 @@ public class AdminConsole {
@Inject
private
EventManager
eventManager
;
/**
* Imports markdown files.
*
* @param context
* @param request
*/
public
void
importMDs
(
final
HTTPRequestContext
context
,
final
HttpServletRequest
request
)
{
}
/**
* Shows administrator index with the specified context.
*
...
...
@@ -149,11 +139,9 @@ public class AdminConsole {
final
JSONObject
currentUser
=
userQueryService
.
getCurrentUser
(
request
);
final
String
userName
=
currentUser
.
optString
(
User
.
USER_NAME
);
dataModel
.
put
(
User
.
USER_NAME
,
userName
);
final
String
roleName
=
currentUser
.
optString
(
User
.
USER_ROLE
);
dataModel
.
put
(
User
.
USER_ROLE
,
roleName
);
final
String
email
=
currentUser
.
optString
(
User
.
USER_EMAIL
);
...
...
@@ -287,7 +275,6 @@ public class AdminConsole {
final
StringBuilder
timeZoneIdOptions
=
new
StringBuilder
();
final
String
[]
availableIDs
=
TimeZone
.
getAvailableIDs
();
for
(
int
i
=
0
;
i
<
availableIDs
.
length
;
i
++)
{
final
String
id
=
availableIDs
[
i
];
String
option
;
...
...
@@ -323,14 +310,14 @@ public class AdminConsole {
return
;
}
if
(!
Latkes
.
runsWithJDBCDatabase
())
{
final
RuntimeDatabase
runtimeDatabase
=
Latkes
.
getRuntimeDatabase
();
if
(
RuntimeDatabase
.
H2
!=
runtimeDatabase
&&
RuntimeDatabase
.
MYSQL
!=
runtimeDatabase
)
{
context
.
renderJSON
().
renderMsg
(
"Just support MySQL/H2 export now"
);
return
;
}
final
RuntimeDatabase
runtimeDatabase
=
Latkes
.
getRuntimeDatabase
();
final
String
dbUser
=
Latkes
.
getLocalProperty
(
"jdbc.username"
);
final
String
dbPwd
=
Latkes
.
getLocalProperty
(
"jdbc.password"
);
final
String
dbURL
=
Latkes
.
getLocalProperty
(
"jdbc.URL"
);
...
...
src/main/java/org/b3log/solo/service/InitService.java
View file @
7d44435d
...
...
@@ -20,7 +20,6 @@ import org.apache.commons.lang.time.DateUtils;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.RuntimeDatabase
;
import
org.b3log.latke.RuntimeEnv
;
import
org.b3log.latke.ioc.inject.Inject
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
...
...
@@ -63,7 +62,7 @@ import java.util.Set;
* Solo initialization service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.5.2.1
1, Nov 8, 2016
* @version 1.5.2.1
2, Jul 6, 2017
* @since 0.4.0
*/
@Service
...
...
@@ -72,7 +71,7 @@ public class InitService {
/**
* Logger.
*/
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
InitService
.
class
.
getName
()
);
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
InitService
.
class
);
/**
* Statistic repository.
...
...
@@ -175,7 +174,6 @@ public class InitService {
/**
* Initializes Solo.
*
* <p>
* Initializes the followings in sequence:
* <ol>
...
...
@@ -184,23 +182,19 @@ public class InitService {
* <li>Administrator</li>
* </ol>
* </p>
*
* <p>
* We will try to initialize Solo 3 times at most.
* </p>
*
* <p>
* Posts "Hello World!" article and its comment while Solo initialized.
* </p>
*
* @param requestJSONObject the specified request json object, for example,
<pre>
* @param requestJSONObject the specified request json object, for example,
* {
* "userName": "",
* "userEmail": "",
* "userPassword": "", // Unhashed
* }
* </pre>
*
* @throws ServiceException service exception
*/
public
void
init
(
final
JSONObject
requestJSONObject
)
throws
ServiceException
{
...
...
@@ -208,11 +202,7 @@ public class InitService {
return
;
}
final
RuntimeEnv
runtimeEnv
=
Latkes
.
getRuntimeEnv
();
if
(
RuntimeEnv
.
LOCAL
==
runtimeEnv
)
{
LOGGER
.
log
(
Level
.
INFO
,
"Solo is running on ["
+
runtimeEnv
+
"] environment, database [{0}], creates "
+
"all tables"
,
Latkes
.
getRuntimeDatabase
());
LOGGER
.
log
(
Level
.
INFO
,
"Solo is running with database [{0}], creates all tables"
,
Latkes
.
getRuntimeDatabase
());
if
(
RuntimeDatabase
.
H2
==
Latkes
.
getRuntimeDatabase
())
{
String
dataDir
=
Latkes
.
getLocalProperty
(
"jdbc.URL"
);
...
...
@@ -226,7 +216,6 @@ public class InitService {
LOGGER
.
log
(
Level
.
DEBUG
,
"Create table result[tableName={0}, isSuccess={1}]"
,
createTableResult
.
getName
(),
createTableResult
.
isSuccess
());
}
}
int
retries
=
MAX_RETRIES_CNT
;
...
...
@@ -281,7 +270,7 @@ public class InitService {
final
HTTPRequest
req
=
new
HTTPRequest
();
req
.
setURL
(
new
URL
(
Latkes
.
getServePath
()
+
"/blog/symphony/user"
));
urlFetchService
.
fetch
(
req
);
urlFetchService
.
fetch
Async
(
req
);
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
TRACE
,
"Sync account failed"
);
}
...
...
@@ -400,15 +389,13 @@ public class InitService {
/**
* Archive the create date with the specified article.
*
* @param article the specified article, for example,
<pre>
* @param article the specified article, for example,
* {
* ....,
* "oId": "",
* "articleCreateDate": java.util.Date,
* ....
* }
* </pre>
*
* @throws RepositoryException repository exception
*/
public
void
archiveDate
(
final
JSONObject
article
)
throws
RepositoryException
{
...
...
@@ -488,14 +475,12 @@ public class InitService {
/**
* Initializes administrator with the specified request json object, and then logins it.
*
* @param requestJSONObject the specified request json object, for example,
<pre>
* @param requestJSONObject the specified request json object, for example,
* {
* "userName": "",
* "userEmail": "",
* "userPassowrd": "" // Unhashed
* }
* </pre>
*
* @throws Exception exception
*/
private
void
initAdmin
(
final
JSONObject
requestJSONObject
)
throws
Exception
{
...
...
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