Commit fe6e4cc2 authored by Liang Ding's avatar Liang Ding

获取管理员方法不抛异常

parent 563c7158
......@@ -77,13 +77,7 @@ public class ImportService {
final String markdownsPath = servletContext.getRealPath("markdowns");
LOGGER.debug("Import directory [" + markdownsPath + "]");
JSONObject admin;
try {
admin = userQueryService.getAdmin();
} catch (final Exception e) {
return;
}
final JSONObject admin = userQueryService.getAdmin();
if (null == admin) { // Not init yet
return;
}
......
......@@ -43,7 +43,7 @@ import java.util.List;
* User query service.
*
* @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
*/
@Service
......@@ -86,14 +86,13 @@ public class UserQueryService {
* Gets the administrator.
*
* @return administrator, returns {@code null} if not found
* @throws ServiceException service exception
*/
public JSONObject getAdmin() throws ServiceException {
public JSONObject getAdmin() {
try {
return userRepository.getAdmin();
} catch (final RepositoryException 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;
import org.b3log.latke.model.User;
import org.b3log.latke.repository.jdbc.util.Connections;
import org.b3log.latke.repository.jdbc.util.JdbcRepositories;
import org.b3log.latke.service.ServiceException;
import org.b3log.latke.util.Crypts;
import org.b3log.solo.cache.*;
import org.b3log.solo.model.Option;
......@@ -134,9 +133,8 @@ public abstract class AbstractTestCase {
* Mocks admin login for console testing.
*
* @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 String userId = adminUser.optString(Keys.OBJECT_ID);
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