Commit 2915ec7f authored by Liang Ding's avatar Liang Ding

#12042

移除 Preference 类
parent 645b162f
/*
* Copyright (c) 2010-2015, b3log.org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.b3log.solo.model;
/**
* This class defines all comment model relevant keys.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.3.0.11, Nov 23, 2015
* @since 0.3.1
* @deprecated this class will be removed in 1.3.0, see issue
* <a href="https://github.com/b3log/solo/issues/12042">#12042</a>
* for more details
*/
public final class Preference {
/**
* Preference.
*/
public static final String PREFERENCE = "preference";
/**
* Private default constructor.
*/
private Preference() {
}
}
......@@ -31,7 +31,6 @@ import org.b3log.latke.servlet.annotation.RequestProcessor;
import org.b3log.latke.servlet.renderer.JSONRenderer;
import org.b3log.latke.util.Requests;
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;
......@@ -243,7 +242,8 @@ public class PreferenceConsole {
final JSONArray signs = new JSONArray();
final JSONArray allSigns = // includes the empty sign(id=0)
final JSONArray allSigns
= // includes the empty sign(id=0)
new JSONArray(preference.getString(Option.ID_C_SIGNS));
for (int i = 1; i < allSigns.length(); i++) { // excludes the empty sign
......@@ -353,7 +353,7 @@ public class PreferenceConsole {
final JSONObject ret = new JSONObject();
renderer.setJSONObject(ret);
ret.put(Preference.PREFERENCE, preference);
ret.put(Option.CATEGORY_C_PREFERENCE, preference);
ret.put(Keys.STATUS_CODE, true);
} catch (final Exception e) {
LOGGER.log(Level.ERROR, e.getMessage(), e);
......@@ -424,7 +424,7 @@ public class PreferenceConsole {
try {
final JSONObject requestJSONObject = Requests.parseRequestJSONObject(request, response);
final JSONObject preference = requestJSONObject.getJSONObject(Preference.PREFERENCE);
final JSONObject preference = requestJSONObject.getJSONObject(Option.CATEGORY_C_PREFERENCE);
final JSONObject ret = new JSONObject();
......@@ -433,7 +433,7 @@ public class PreferenceConsole {
if (isInvalid(preference, ret)) {
return;
}
preferenceMgmtService.updatePreference(preference);
ret.put(Keys.STATUS_CODE, true);
......
......@@ -15,22 +15,21 @@
*/
package org.b3log.solo.repository.impl;
import org.b3log.latke.repository.AbstractRepository;
import org.b3log.latke.repository.RepositoryException;
import org.b3log.latke.repository.annotation.Repository;
import org.b3log.solo.model.Preference;
import org.b3log.solo.model.Option;
import org.b3log.solo.repository.PreferenceRepository;
import org.json.JSONObject;
/**
* Preference repository.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.3, Feb 28, 2012
* @version 1.0.0.4, Nov 23, 2015
* @since 0.3.1
* @deprecated this class will be removed in 1.3.0, see issue <a href="https://github.com/b3log/solo/issues/12042">#12042</a>
* @deprecated this class will be removed in 1.3.0, see issue
* <a href="https://github.com/b3log/solo/issues/12042">#12042</a>
* for more details
*/
@Repository
......@@ -40,16 +39,15 @@ public class PreferenceRepositoryImpl extends AbstractRepository implements Pref
* Public constructor.
*/
public PreferenceRepositoryImpl() {
super(Preference.PREFERENCE);
super(Option.CATEGORY_C_PREFERENCE);
}
/**
* {@inheritDoc}
*
*
* <p>
* Bypasses {@linkplain org.b3log.latke.repository.Repositories validation}
* against the repository structure, adds the specified json object as
* preference directly.
* Bypasses {@linkplain org.b3log.latke.repository.Repositories validation} against the repository structure, adds
* the specified json object as preference directly.
* </p>
*/
@Override
......@@ -59,11 +57,10 @@ public class PreferenceRepositoryImpl extends AbstractRepository implements Pref
/**
* {@inheritDoc}
*
*
* <p>
* Bypasses {@linkplain org.b3log.latke.repository.Repositories validation}
* against the repository structure, adds the specified json object as
* preference directly.
* Bypasses {@linkplain org.b3log.latke.repository.Repositories validation} against the repository structure, adds
* the specified json object as preference directly.
* </p>
*/
@Override
......
......@@ -121,7 +121,7 @@ public class UpgradeService {
*/
public void upgrade() {
try {
final JSONObject preference = preferenceRepository.get(Preference.PREFERENCE);
final JSONObject preference = preferenceRepository.get(Option.CATEGORY_C_PREFERENCE);
if (null == preference) {
return;
}
......@@ -180,7 +180,7 @@ public class UpgradeService {
upgradeUsers();
// Upgrades preference model
final JSONObject preference = preferenceRepository.get(Preference.PREFERENCE);
final JSONObject preference = preferenceRepository.get(Option.CATEGORY_C_PREFERENCE);
final String adminEmail = preference.optString(Option.ID_C_ADMIN_EMAIL);
final JSONObject adminEmailOpt = new JSONObject();
......@@ -434,7 +434,7 @@ public class UpgradeService {
optionRepository.add(allowRegisterOpt);
preference.put(Option.ID_C_VERSION, TO_VER);
preferenceRepository.update(Preference.PREFERENCE, preference);
preferenceRepository.update(Option.CATEGORY_C_PREFERENCE, preference);
transaction.commit();
......
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