Commit fe6e4cc2 authored by Liang Ding's avatar Liang Ding

获取管理员方法不抛异常

parent 563c7158
...@@ -77,13 +77,7 @@ public class ImportService { ...@@ -77,13 +77,7 @@ public class ImportService {
final String markdownsPath = servletContext.getRealPath("markdowns"); final String markdownsPath = servletContext.getRealPath("markdowns");
LOGGER.debug("Import directory [" + markdownsPath + "]"); LOGGER.debug("Import directory [" + markdownsPath + "]");
JSONObject admin; final JSONObject admin = userQueryService.getAdmin();
try {
admin = userQueryService.getAdmin();
} catch (final Exception e) {
return;
}
if (null == admin) { // Not init yet if (null == admin) { // Not init yet
return; return;
} }
......
...@@ -43,7 +43,7 @@ import java.util.List; ...@@ -43,7 +43,7 @@ import java.util.List;
* User query service. * User query service.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.0, Feb 3, 2019 * @version 1.1.0.1, Oct 2, 2019
* @since 0.4.0 * @since 0.4.0
*/ */
@Service @Service
...@@ -86,14 +86,13 @@ public class UserQueryService { ...@@ -86,14 +86,13 @@ public class UserQueryService {
* Gets the administrator. * Gets the administrator.
* *
* @return administrator, returns {@code null} if not found * @return administrator, returns {@code null} if not found
* @throws ServiceException service exception
*/ */
public JSONObject getAdmin() throws ServiceException { public JSONObject getAdmin() {
try { try {
return userRepository.getAdmin(); return userRepository.getAdmin();
} catch (final RepositoryException e) { } catch (final RepositoryException e) {
LOGGER.log(Level.ERROR, "Gets admin failed", e); LOGGER.log(Level.ERROR, "Gets admin failed", e);
throw new ServiceException(e); return null;
} }
} }
......
...@@ -25,7 +25,6 @@ import org.b3log.latke.ioc.Discoverer; ...@@ -25,7 +25,6 @@ import org.b3log.latke.ioc.Discoverer;
import org.b3log.latke.model.User; import org.b3log.latke.model.User;
import org.b3log.latke.repository.jdbc.util.Connections; 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.service.ServiceException;
import org.b3log.latke.util.Crypts; import org.b3log.latke.util.Crypts;
import org.b3log.solo.cache.*; import org.b3log.solo.cache.*;
import org.b3log.solo.model.Option; import org.b3log.solo.model.Option;
...@@ -134,9 +133,8 @@ public abstract class AbstractTestCase { ...@@ -134,9 +133,8 @@ public abstract class AbstractTestCase {
* Mocks admin login for console testing. * Mocks admin login for console testing.
* *
* @param request the specified request * @param request the specified request
* @throws ServiceException service exception
*/ */
public void mockAdminLogin(final MockHttpServletRequest request) throws ServiceException { public void mockAdminLogin(final MockHttpServletRequest request) {
final JSONObject adminUser = getUserQueryService().getAdmin(); final JSONObject adminUser = getUserQueryService().getAdmin();
final String userId = adminUser.optString(Keys.OBJECT_ID); final String userId = adminUser.optString(Keys.OBJECT_ID);
final JSONObject cookieJSONObject = new JSONObject(); final JSONObject cookieJSONObject = new JSONObject();
......
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