Commit 7d44435d authored by Liang Ding's avatar Liang Ding

🔨 适应 Latke 框架调整

parent 15618f0f
......@@ -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 26, 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"));
......
......@@ -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 26, 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"));
......
......@@ -43,9 +43,9 @@ 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));
......@@ -131,7 +130,7 @@ public final class CommentSender extends AbstractEventListener<JSONObject> {
/**
* Gets the event type {@linkplain EventTypes#ADD_COMMENT_TO_ARTICLE}.
*
*
* @return event type
*/
@Override
......
......@@ -50,9 +50,9 @@ import java.util.concurrent.Future;
/**
* Broadcast chance processor.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.10, Nov 20, 2015
* @version 1.0.0.11, 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.
......@@ -85,7 +85,7 @@ public class ChanceProcessor {
*/
@Inject
private UserQueryService userQueryService;
/**
* Preference query 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>
......@@ -119,27 +118,23 @@ public class ChanceProcessor {
* </pre>
* </p>
*
* @param context the specified http request context
* @param request the specified http servlet request
* @param context the specified http request context
* @param request the specified http servlet request
* @param response the specified http servlet response
* @throws Exception
* @throws Exception
*/
@RequestProcessing(value = "/console/plugins/b3log-broadcast/chance", method = HTTPRequestMethod.POST)
public void addChance(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response)
throws Exception {
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>
......@@ -186,14 +177,14 @@ public class ChanceProcessor {
* </pre>
* </p>
*
* @param context the specified http request context
* @param request the specified http servlet request
* @param context the specified http request context
* @param request the specified http servlet request
* @param response the specified http servlet response
* @throws Exception
* @throws Exception
*/
@RequestProcessing(value = "/console/plugins/b3log-broadcast/chance", method = HTTPRequestMethod.GET)
public void hasChance(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response)
throws Exception {
throws Exception {
if (!userQueryService.isLoggedIn(request, response)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
......@@ -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>
......@@ -249,23 +235,21 @@ public class ChanceProcessor {
* </pre>
* </p>
*
* @param context the specified http request context
* @param request the specified http servlet request, for example,
* <pre>
* {
* "broadcast": {
* "title": "",
* "content": "",
* "link": "" // optional
* }
* }
* </pre>
* @param context the specified http request context
* @param request the specified http servlet request, for example,
* {
* "broadcast": {
* "title": "",
* "content": "",
* "link": "" // optional
* }
* }
* @param response the specified http servlet response
* @throws Exception
* @throws Exception
*/
@RequestProcessing(value = "/console/plugins/b3log-broadcast", method = HTTPRequestMethod.POST)
public void submitBroadcast(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response)
throws Exception {
throws Exception {
if (!userQueryService.isAdminLoggedIn(request)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
......@@ -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()) {
......
......@@ -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,12 +132,7 @@ 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());
}
jsonObject.put("runtimeDatabase", Latkes.getRuntimeDatabase());
}
/**
......@@ -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,9 +186,10 @@ public class BlogProcessor {
* ]
* }
* </pre>
* </p>
*
* @param context the specified context
* @param request the specified HTTP servlet request
* @param context the specified context
* @param request the specified HTTP servlet request
* @param response the specified HTTP servlet response
* @throws Exception io exception
*/
......@@ -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,15 +259,16 @@ 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
* @param context the specified context
* @param request the specified HTTP servlet request
* @param response the specified HTTP servlet response
* @throws Exception io exception
*/
......
......@@ -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.
......@@ -84,7 +79,7 @@ public class CaptchaProcessor {
/**
* Gets captcha.
*
*
* @param context the specified context
*/
@RequestProcessing(value = "/captcha.do", method = HTTPRequestMethod.GET)
......@@ -132,23 +127,15 @@ public class CaptchaProcessor {
try {
captchas = new Image[CAPTCHA_COUNT];
ZipFile zipFile;
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);
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);
final ZipFile zipFile = new ZipFile(file);
IOUtils.copy(inputStream, outputStream);
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());
}
IOUtils.closeQuietly(inputStream);
IOUtils.closeQuietly(outputStream);
final Enumeration<? extends ZipEntry> entries = zipFile.entries();
......
......@@ -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.11, Jun 18, 2017
* @version 1.5.2.12, 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");
......
......@@ -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.11, Nov 8, 2016
* @version 1.5.2.12, 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>
* {
* "userName": "",
* "userEmail": "",
* "userPassword": "", // Unhashed
* }
* </pre>
*
* @param requestJSONObject the specified request json object, for example,
* {
* "userName": "",
* "userEmail": "",
* "userPassword": "", // Unhashed
* }
* @throws ServiceException service exception
*/
public void init(final JSONObject requestJSONObject) throws ServiceException {
......@@ -208,24 +202,19 @@ 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");
dataDir = dataDir.replace("~", System.getProperty("user.home"));
LOGGER.log(Level.INFO, "YOUR DATA will be stored in directory [" + dataDir + "], "
+ "please pay more attention to it~");
}
if (RuntimeDatabase.H2 == Latkes.getRuntimeDatabase()) {
String dataDir = Latkes.getLocalProperty("jdbc.URL");
dataDir = dataDir.replace("~", System.getProperty("user.home"));
LOGGER.log(Level.INFO, "YOUR DATA will be stored in directory [" + dataDir + "], "
+ "please pay more attention to it~");
}
final List<CreateTableResult> createTableResults = JdbcRepositories.initAllTables();
for (final CreateTableResult createTableResult : createTableResults) {
LOGGER.log(Level.DEBUG, "Create table result[tableName={0}, isSuccess={1}]",
createTableResult.getName(), createTableResult.isSuccess());
}
final List<CreateTableResult> createTableResults = JdbcRepositories.initAllTables();
for (final CreateTableResult createTableResult : createTableResults) {
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.fetchAsync(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>
* {
* ....,
* "oId": "",
* "articleCreateDate": java.util.Date,
* ....
* }
* </pre>
*
* @param article the specified article, for example,
* {
* ....,
* "oId": "",
* "articleCreateDate": java.util.Date,
* ....
* }
* @throws RepositoryException repository exception
*/
public void archiveDate(final JSONObject article) throws RepositoryException {
......@@ -438,7 +425,7 @@ public class InitService {
/**
* Adds relation of the specified tags and article.
*
* @param tags the specified tags
* @param tags the specified tags
* @param article the specified article
* @throws RepositoryException repository exception
*/
......@@ -458,7 +445,7 @@ public class InitService {
* Tags the specified article with the specified tag titles.
*
* @param tagTitles the specified tag titles
* @param article the specified article
* @param article the specified article
* @return an array of tags
* @throws RepositoryException repository exception
*/
......@@ -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>
* {
* "userName": "",
* "userEmail": "",
* "userPassowrd": "" // Unhashed
* }
* </pre>
*
* @param requestJSONObject the specified request json object, for example,
* {
* "userName": "",
* "userEmail": "",
* "userPassowrd": "" // Unhashed
* }
* @throws Exception exception
*/
private void initAdmin(final JSONObject requestJSONObject) throws Exception {
......@@ -538,7 +523,7 @@ public class InitService {
* Initializes statistic.
*
* @throws RepositoryException repository exception
* @throws JSONException json exception
* @throws JSONException json exception
*/
private void initStatistic() throws RepositoryException, JSONException {
LOGGER.debug("Initializing statistic....");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment