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; ...@@ -31,7 +31,6 @@ import org.b3log.latke.servlet.annotation.RequestProcessor;
import org.b3log.latke.servlet.renderer.JSONRenderer; import org.b3log.latke.servlet.renderer.JSONRenderer;
import org.b3log.latke.util.Requests; import org.b3log.latke.util.Requests;
import org.b3log.solo.model.Option; import org.b3log.solo.model.Option;
import org.b3log.solo.model.Preference;
import org.b3log.solo.model.Sign; import org.b3log.solo.model.Sign;
import org.b3log.solo.service.OptionMgmtService; import org.b3log.solo.service.OptionMgmtService;
import org.b3log.solo.service.OptionQueryService; import org.b3log.solo.service.OptionQueryService;
...@@ -243,7 +242,8 @@ public class PreferenceConsole { ...@@ -243,7 +242,8 @@ public class PreferenceConsole {
final JSONArray signs = new JSONArray(); 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)); new JSONArray(preference.getString(Option.ID_C_SIGNS));
for (int i = 1; i < allSigns.length(); i++) { // excludes the empty sign for (int i = 1; i < allSigns.length(); i++) { // excludes the empty sign
...@@ -353,7 +353,7 @@ public class PreferenceConsole { ...@@ -353,7 +353,7 @@ public class PreferenceConsole {
final JSONObject ret = new JSONObject(); final JSONObject ret = new JSONObject();
renderer.setJSONObject(ret); renderer.setJSONObject(ret);
ret.put(Preference.PREFERENCE, preference); ret.put(Option.CATEGORY_C_PREFERENCE, preference);
ret.put(Keys.STATUS_CODE, true); ret.put(Keys.STATUS_CODE, true);
} catch (final Exception e) { } catch (final Exception e) {
LOGGER.log(Level.ERROR, e.getMessage(), e); LOGGER.log(Level.ERROR, e.getMessage(), e);
...@@ -424,7 +424,7 @@ public class PreferenceConsole { ...@@ -424,7 +424,7 @@ public class PreferenceConsole {
try { try {
final JSONObject requestJSONObject = Requests.parseRequestJSONObject(request, response); 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(); final JSONObject ret = new JSONObject();
...@@ -433,7 +433,7 @@ public class PreferenceConsole { ...@@ -433,7 +433,7 @@ public class PreferenceConsole {
if (isInvalid(preference, ret)) { if (isInvalid(preference, ret)) {
return; return;
} }
preferenceMgmtService.updatePreference(preference); preferenceMgmtService.updatePreference(preference);
ret.put(Keys.STATUS_CODE, true); ret.put(Keys.STATUS_CODE, true);
......
...@@ -15,22 +15,21 @@ ...@@ -15,22 +15,21 @@
*/ */
package org.b3log.solo.repository.impl; package org.b3log.solo.repository.impl;
import org.b3log.latke.repository.AbstractRepository; import org.b3log.latke.repository.AbstractRepository;
import org.b3log.latke.repository.RepositoryException; import org.b3log.latke.repository.RepositoryException;
import org.b3log.latke.repository.annotation.Repository; 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.b3log.solo.repository.PreferenceRepository;
import org.json.JSONObject; import org.json.JSONObject;
/** /**
* Preference repository. * Preference repository.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @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 * for more details
*/ */
@Repository @Repository
...@@ -40,16 +39,15 @@ public class PreferenceRepositoryImpl extends AbstractRepository implements Pref ...@@ -40,16 +39,15 @@ public class PreferenceRepositoryImpl extends AbstractRepository implements Pref
* Public constructor. * Public constructor.
*/ */
public PreferenceRepositoryImpl() { public PreferenceRepositoryImpl() {
super(Preference.PREFERENCE); super(Option.CATEGORY_C_PREFERENCE);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
* *
* <p> * <p>
* Bypasses {@linkplain org.b3log.latke.repository.Repositories validation} * Bypasses {@linkplain org.b3log.latke.repository.Repositories validation} against the repository structure, adds
* against the repository structure, adds the specified json object as * the specified json object as preference directly.
* preference directly.
* </p> * </p>
*/ */
@Override @Override
...@@ -59,11 +57,10 @@ public class PreferenceRepositoryImpl extends AbstractRepository implements Pref ...@@ -59,11 +57,10 @@ public class PreferenceRepositoryImpl extends AbstractRepository implements Pref
/** /**
* {@inheritDoc} * {@inheritDoc}
* *
* <p> * <p>
* Bypasses {@linkplain org.b3log.latke.repository.Repositories validation} * Bypasses {@linkplain org.b3log.latke.repository.Repositories validation} against the repository structure, adds
* against the repository structure, adds the specified json object as * the specified json object as preference directly.
* preference directly.
* </p> * </p>
*/ */
@Override @Override
......
...@@ -121,7 +121,7 @@ public class UpgradeService { ...@@ -121,7 +121,7 @@ public class UpgradeService {
*/ */
public void upgrade() { public void upgrade() {
try { try {
final JSONObject preference = preferenceRepository.get(Preference.PREFERENCE); final JSONObject preference = preferenceRepository.get(Option.CATEGORY_C_PREFERENCE);
if (null == preference) { if (null == preference) {
return; return;
} }
...@@ -180,7 +180,7 @@ public class UpgradeService { ...@@ -180,7 +180,7 @@ public class UpgradeService {
upgradeUsers(); upgradeUsers();
// Upgrades preference model // 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 String adminEmail = preference.optString(Option.ID_C_ADMIN_EMAIL);
final JSONObject adminEmailOpt = new JSONObject(); final JSONObject adminEmailOpt = new JSONObject();
...@@ -434,7 +434,7 @@ public class UpgradeService { ...@@ -434,7 +434,7 @@ public class UpgradeService {
optionRepository.add(allowRegisterOpt); optionRepository.add(allowRegisterOpt);
preference.put(Option.ID_C_VERSION, TO_VER); preference.put(Option.ID_C_VERSION, TO_VER);
preferenceRepository.update(Preference.PREFERENCE, preference); preferenceRepository.update(Option.CATEGORY_C_PREFERENCE, preference);
transaction.commit(); 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