Commit ef068c6a authored by Liang Ding's avatar Liang Ding

#12029

parent f5eb32da
<?xml version="1.0" encoding="UTF-8"?>
<!--
Description: Solo core.
Version: 2.3.1.7, Jun 28, 2015
Version: 2.4.1.7, Sep 12, 2015
Author: Liang Ding
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
......@@ -82,6 +82,11 @@
<artifactId>markdownpapers-core</artifactId>
</dependency>
<dependency>
<groupId>com.qiniu</groupId>
<artifactId>qiniu-java-sdk</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
......
......@@ -33,6 +33,7 @@ import org.b3log.solo.model.Option;
import org.b3log.solo.model.Preference;
import org.b3log.solo.model.Sign;
import org.b3log.solo.service.OptionMgmtService;
import org.b3log.solo.service.OptionQueryService;
import org.b3log.solo.service.PreferenceMgmtService;
import org.b3log.solo.service.PreferenceQueryService;
import org.b3log.solo.service.UserQueryService;
......@@ -73,6 +74,12 @@ public class PreferenceConsole {
@Inject
private OptionMgmtService optionMgmtService;
/**
* Option query service.
*/
@Inject
private OptionQueryService optionQueryService;
/**
* User query service.
*/
......@@ -429,6 +436,63 @@ public class PreferenceConsole {
}
}
/**
* Gets Qiniu preference.
*
* <p>
* Renders the response with a json object, for example,
* <pre>
* {
* "sc": boolean,
* "qiniuAccessKey": "",
* "qiniuSecretKey": "",
* "qiniuDomain": "",
* "qiniuBucket": ""
* }
* </pre>
* </p>
*
* @param request the specified http servlet request
* @param response the specified http servlet response
* @param context the specified http request context
* @throws Exception exception
*/
@RequestProcessing(value = PREFERENCE_URI_PREFIX + "qiniu", method = HTTPRequestMethod.GET)
public void getQiniuPreference(final HttpServletRequest request, final HttpServletResponse response,
final HTTPRequestContext context) throws Exception {
if (!userQueryService.isAdminLoggedIn(request)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
final JSONRenderer renderer = new JSONRenderer();
context.setRenderer(renderer);
try {
final JSONObject qiniu = optionQueryService.getOptions(Option.CATEGORY_C_QINIU);
if (null == qiniu) {
renderer.setJSONObject(QueryResults.defaultResult());
return;
}
final JSONObject ret = new JSONObject();
renderer.setJSONObject(ret);
ret.put(Option.CATEGORY_C_QINIU, qiniu);
ret.put(Keys.STATUS_CODE, true);
} catch (final Exception e) {
LOGGER.log(Level.ERROR, e.getMessage(), e);
final JSONObject jsonObject = QueryResults.defaultResult();
renderer.setJSONObject(jsonObject);
jsonObject.put(Keys.MSG, langPropsService.get("getFailLabel"));
}
}
/**
* Updates the Qiniu preference by the specified request.
*
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
Description: Solo parent POM.
Version: 2.4.4.20, Jun 28, 2015
Version: 2.5.4.20, Sep 12, 2015
Author: Liang Ding
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
......@@ -37,6 +37,8 @@
<freemarker-gae.version>2.3.20</freemarker-gae.version>
<jsoup.version>1.5.2</jsoup.version>
<markdownpapers-core.version>1.3.2</markdownpapers-core.version>
<qiniu.version>7.0.4.1</qiniu.version>
<!-- maven plugin -->
<maven-compiler-plugin.version>2.3.2</maven-compiler-plugin.version>
<maven-resources-plugin.version>2.5</maven-resources-plugin.version>
......@@ -224,6 +226,12 @@
<version>${markdownpapers-core.version}</version>
</dependency>
<dependency>
<groupId>com.qiniu</groupId>
<artifactId>qiniu-java-sdk</artifactId>
<version>${qiniu.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
......
......@@ -22,6 +22,10 @@
# Author: Dongxu Wang
#
accessKey1Label=Access Key:
secretKey1Label=Secret Key:
domain1Label=\u57df\u540d:
bucketKey1Label=Bucket:
qiniuLabel=Qiniu
contributorsLabel=Contributors
developersLabel=Developers
......
......@@ -22,6 +22,10 @@
# Author: Dongxu Wang
#
accessKey1Label=Access Key\uff1a
secretKey1Label=Secret Key\uff1a
domain1Label=\u57df\u540d\uff1a
bucketKey1Label=Bucket\uff1a
qiniuLabel=\u4e03\u725b
contributorsLabel=\u8d21\u732e\u8005
developersLabel=\u5f00\u53d1\u8005
......
......@@ -358,7 +358,7 @@
</tr>
<tr>
<th>
<label for="qiniuAccessKey">AccessKey</label>
<label for="qiniuAccessKey">${accessKey1Label}</label>
</th>
<td>
<input id="qiniuAccessKey" class="normalInput" type="text"/>
......@@ -366,7 +366,7 @@
</tr>
<tr>
<th>
<label for="qiniuSecretKey">SecretKey</label>
<label for="qiniuSecretKey">${secretKey1Label}</label>
</th>
<td>
<input id="qiniuSecretKey" class="normalInput" type="text"/>
......@@ -374,7 +374,7 @@
</tr>
<tr>
<th>
<label for="qiniuDomain">Domain</label>
<label for="qiniuDomain">${domain1Label}</label>
</th>
<td>
<input id="qiniuDomain" class="normalInput" type="text"/>
......@@ -382,7 +382,7 @@
</tr>
<tr>
<th>
<label for="qiniuBucket">Bucket</label>
<label for="qiniuBucket">${bucket1Label}</label>
</th>
<td>
<input id="qiniuBucket" class="normalInput" type="text"/>
......
......@@ -2928,6 +2928,24 @@ admin.preference = {
$("#loadMsg").text("");
}
});
$.ajax({
url: latkeConfig.servePath + "/console/preference/qiniu",
type: "GET",
cache: false,
success: function (result, textStatus) {
$("#tipMsg").text(result.msg);
if (!result.sc) {
$("#loadMsg").text("");
return;
}
$("#qiniuAccessKey").val(result.qiniu.qiniuAccessKey);
$("#qiniuSecretKey").val(result.qiniu.qiniuSecretKey);
$("#qiniuDomain").val(result.qiniu.qiniuDomain);
$("#qiniuBucket").val(result.qiniu.qiniuBucket);
}
});
},
/*
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -113,6 +113,24 @@ admin.preference = {
$("#loadMsg").text("");
}
});
$.ajax({
url: latkeConfig.servePath + "/console/preference/qiniu",
type: "GET",
cache: false,
success: function (result, textStatus) {
$("#tipMsg").text(result.msg);
if (!result.sc) {
$("#loadMsg").text("");
return;
}
$("#qiniuAccessKey").val(result.qiniu.qiniuAccessKey);
$("#qiniuSecretKey").val(result.qiniu.qiniuSecretKey);
$("#qiniuDomain").val(result.qiniu.qiniuDomain);
$("#qiniuBucket").val(result.qiniu.qiniuBucket);
}
});
},
/*
......
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