Commit ce5846fb authored by Van's avatar Van

Merge remote-tracking branch 'origin/2.9.8-dev' into 2.9.8-dev

parents 58a5199d 6b11e52c
...@@ -49,7 +49,7 @@ import static org.b3log.solo.model.Option.*; ...@@ -49,7 +49,7 @@ import static org.b3log.solo.model.Option.*;
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="https://github.com/hzchendou">hzchendou</a> * @author <a href="https://github.com/hzchendou">hzchendou</a>
* @version 1.2.0.18, Dec 23, 2018 * @version 1.2.0.19, Dec 24, 2018
* @since 0.4.0 * @since 0.4.0
*/ */
@RequestProcessor @RequestProcessor
...@@ -398,12 +398,14 @@ public class PreferenceConsole { ...@@ -398,12 +398,14 @@ public class PreferenceConsole {
public void getOssPreference(final RequestContext context) { public void getOssPreference(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
context.setRenderer(renderer); context.setRenderer(renderer);
final JSONObject ret = new JSONObject();
renderer.setJSONObject(ret);
try { try {
String ossServerVal = CATEGORY_C_QINIU; String ossServerVal = CATEGORY_C_QINIU;
// 前端服务商切换 ossServer // 前端服务商切换 ossServer
String ossServerTemp = context.param(ID_C_CLOUD_STORAGE_KEY); String ossServerTemp = context.param(ID_C_CLOUD_STORAGE_KEY);
if (ossServerTemp != null && ossServerTemp.length() > 0) { if (StringUtils.isNotBlank(ossServerTemp)) {
ossServerVal = ossServerTemp; ossServerVal = ossServerTemp;
} else { } else {
final JSONObject ossServer = optionQueryService.getOptions(CATEGORY_C_CLOU_STORAGE); final JSONObject ossServer = optionQueryService.getOptions(CATEGORY_C_CLOU_STORAGE);
...@@ -412,15 +414,11 @@ public class PreferenceConsole { ...@@ -412,15 +414,11 @@ public class PreferenceConsole {
} }
} }
final JSONObject oss = optionQueryService.getOptions(ossServerVal); JSONObject oss = optionQueryService.getOptions(ossServerVal);
if (null == oss) { if (null == oss) {
renderer.setJSONObject(new JSONObject().put(Keys.STATUS_CODE, false)); oss = new JSONObject();
return;
} }
final JSONObject ret = new JSONObject();
renderer.setJSONObject(ret);
ret.put("oss", convertOssOpts(ossServerVal, oss)); ret.put("oss", convertOssOpts(ossServerVal, oss));
ret.put(Keys.STATUS_CODE, true); ret.put(Keys.STATUS_CODE, true);
} catch (final Exception e) { } catch (final Exception e) {
...@@ -652,15 +650,15 @@ public class PreferenceConsole { ...@@ -652,15 +650,15 @@ public class PreferenceConsole {
boolean isAliyunServer = StringUtils.endsWithIgnoreCase(ossServer, CATEGORY_C_ALIYUN); boolean isAliyunServer = StringUtils.endsWithIgnoreCase(ossServer, CATEGORY_C_ALIYUN);
boolean isQiniuServer = StringUtils.endsWithIgnoreCase(ossServer, CATEGORY_C_QINIU); boolean isQiniuServer = StringUtils.endsWithIgnoreCase(ossServer, CATEGORY_C_QINIU);
if (isAliyunServer) { if (isAliyunServer) {
ret.put("ossAccessKey", oss.getString(ID_C_ALIYUN_ACCESS_KEY)); ret.put("ossAccessKey", oss.optString(ID_C_ALIYUN_ACCESS_KEY));
ret.put("ossSecretKey", oss.getString(ID_C_ALIYUN_SECRET_KEY)); ret.put("ossSecretKey", oss.optString(ID_C_ALIYUN_SECRET_KEY));
ret.put("ossDomain", oss.getString(ID_C_ALIYUN_DOMAIN)); ret.put("ossDomain", oss.optString(ID_C_ALIYUN_DOMAIN));
ret.put("ossBucket", oss.getString(ID_C_ALIYUN_BUCKET)); ret.put("ossBucket", oss.optString(ID_C_ALIYUN_BUCKET));
} else if (isQiniuServer) { } else if (isQiniuServer) {
ret.put("ossAccessKey", oss.getString(ID_C_QINIU_ACCESS_KEY)); ret.put("ossAccessKey", oss.optString(ID_C_QINIU_ACCESS_KEY));
ret.put("ossSecretKey", oss.getString(ID_C_QINIU_SECRET_KEY)); ret.put("ossSecretKey", oss.optString(ID_C_QINIU_SECRET_KEY));
ret.put("ossDomain", oss.getString(ID_C_QINIU_DOMAIN)); ret.put("ossDomain", oss.optString(ID_C_QINIU_DOMAIN));
ret.put("ossBucket", oss.getString(ID_C_QINIU_BUCKET)); ret.put("ossBucket", oss.optString(ID_C_QINIU_BUCKET));
} else { } else {
final String msg = "Unknown OSS server [" + ossServer + "]"; final String msg = "Unknown OSS server [" + ossServer + "]";
LOGGER.log(Level.ERROR, msg); LOGGER.log(Level.ERROR, msg);
......
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