Commit 60438056 authored by Liang Ding's avatar Liang Ding

🎨 修复初始化判断问题

parent 3d2ad682
......@@ -51,7 +51,7 @@ import javax.servlet.http.HttpSessionEvent;
* Solo Servlet listener.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.10.0.2, Oct 31, 2018
* @version 1.10.0.3, Nov 6, 2018
* @since 0.3.1
*/
public final class SoloServletListener extends AbstractServletListener {
......@@ -174,9 +174,6 @@ public final class SoloServletListener extends AbstractServletListener {
try {
preference = preferenceQueryService.getPreference();
if (null == preference) {
LOGGER.info("Please open browser and visit [" + Latkes.getServePath() + "] to init your Solo, "
+ "and then enjoy it :-p");
return;
}
......
......@@ -26,7 +26,6 @@ import org.b3log.latke.ioc.Inject;
import org.b3log.latke.logging.Level;
import org.b3log.latke.logging.Logger;
import org.b3log.latke.repository.Transaction;
import org.b3log.latke.service.ServiceException;
import org.b3log.latke.servlet.HTTPRequestContext;
import org.b3log.latke.servlet.HTTPRequestMethod;
import org.b3log.latke.servlet.annotation.RequestProcessing;
......@@ -53,7 +52,7 @@ import java.util.Date;
* Comment receiver from B3log Symphony.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.1.18, Sep 25, 2018
* @version 1.1.1.19, Nov 6, 2018
* @since 0.5.5
*/
@RequestProcessor
......@@ -256,7 +255,7 @@ public class B3CommentReceiver {
ret.put(Keys.STATUS_CODE, true);
renderer.setJSONObject(ret);
} catch (final ServiceException e) {
} catch (final Exception e) {
LOGGER.log(Level.ERROR, e.getMessage(), e);
final JSONObject jsonObject = new JSONObject().put(Keys.STATUS_CODE, false);
......
......@@ -34,7 +34,6 @@ import org.b3log.latke.model.User;
import org.b3log.latke.plugin.ViewLoadEventData;
import org.b3log.latke.repository.jdbc.util.Connections;
import org.b3log.latke.service.LangPropsService;
import org.b3log.latke.service.ServiceException;
import org.b3log.latke.servlet.HTTPRequestContext;
import org.b3log.latke.servlet.HTTPRequestMethod;
import org.b3log.latke.servlet.annotation.Before;
......@@ -68,7 +67,7 @@ import java.util.*;
* Admin console render processing.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.7.0.6, Oct 5, 2018
* @version 1.7.0.7, Nov 6, 2018
* @since 0.4.1
*/
@RequestProcessor
......@@ -241,13 +240,7 @@ public class AdminConsole {
dataModel.putAll(langs);
dataModel.put(Option.ID_C_LOCALE_STRING, locale.toString());
JSONObject preference = null;
try {
preference = preferenceQueryService.getPreference();
} catch (final ServiceException e) {
LOGGER.log(Level.ERROR, "Loads preference failed", e);
}
final JSONObject preference = preferenceQueryService.getPreference();
final StringBuilder timeZoneIdOptions = new StringBuilder();
final String[] availableIDs = TimeZone.getAvailableIDs();
for (int i = 0; i < availableIDs.length; i++) {
......
......@@ -53,7 +53,7 @@ import static org.b3log.solo.model.Article.*;
* @author <a href="http://blog.sweelia.com">ArmstrongCN</a>
* @author <a href="http://zephyr.b3log.org">Zephyr</a>
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @version 1.3.2.6, Oct 7, 2018
* @version 1.3.2.7, Nov 6, 2018
* @since 0.3.5
*/
@Service
......@@ -160,7 +160,7 @@ public class ArticleQueryService {
final List<JSONObject> articles = CollectionUtils.jsonArrayToList(result.optJSONArray(Keys.RESULTS));
ret.put(Article.ARTICLES, (Object) articles);
} catch (final RepositoryException | ServiceException e) {
} catch (final RepositoryException e) {
LOGGER.log(Level.ERROR, "Searches articles error", e);
}
......@@ -244,7 +244,7 @@ public class ArticleQueryService {
ret.put(Article.ARTICLES, (Object) articles);
return ret;
} catch (final RepositoryException | ServiceException e) {
} catch (final RepositoryException e) {
LOGGER.log(Level.ERROR, "Gets category articles error", e);
throw new ServiceException(e);
......
......@@ -57,7 +57,7 @@ import java.util.Set;
* Solo initialization service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.5.2.23, Sep 16, 2018
* @version 1.5.2.24, Nov 6, 2018
* @since 0.4.0
*/
@Service
......@@ -159,9 +159,10 @@ public class InitService {
try {
final JSONObject admin = userRepository.getAdmin();
return null != admin;
} catch (final RepositoryException e) {
LOGGER.log(Level.WARN, "Solo has not been initialized");
return null != admin && 0 < optionRepository.count();
} catch (final Exception e) {
LOGGER.log(Level.WARN, "Solo has not been initialized, please open your browser and visit [" + Latkes.getServePath() + "] to init Solo");
return false;
}
}
......
......@@ -20,7 +20,6 @@ package org.b3log.solo.service;
import org.b3log.latke.ioc.Inject;
import org.b3log.latke.logging.Level;
import org.b3log.latke.logging.Logger;
import org.b3log.latke.repository.RepositoryException;
import org.b3log.latke.service.ServiceException;
import org.b3log.latke.service.annotation.Service;
import org.b3log.solo.model.Option;
......@@ -31,7 +30,7 @@ import org.json.JSONObject;
* Preference query service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.4, Sep 17, 2018
* @version 1.1.0.5, Nov 6, 2018
* @since 0.4.0
*/
@Service
......@@ -79,9 +78,8 @@ public class PreferenceQueryService {
* Gets the user preference.
*
* @return user preference, returns {@code null} if not found
* @throws ServiceException if repository exception
*/
public JSONObject getPreference() throws ServiceException {
public JSONObject getPreference() {
try {
final JSONObject checkInit = optionRepository.get(Option.ID_C_ADMIN_EMAIL);
if (null == checkInit) {
......@@ -89,7 +87,7 @@ public class PreferenceQueryService {
}
return optionQueryService.getOptions(Option.CATEGORY_C_PREFERENCE);
} catch (final RepositoryException e) {
} catch (final Exception e) {
return null;
}
}
......
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