Commit 3ff4c518 authored by Liang Ding's avatar Liang Ding

🔧 1.9.0 -> 2.0.0 升级程序

parent 83955412
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
Description: Solo POM. Description: Solo POM.
Version: 3.16.1.33, Apr 9, 2017 Version: 3.16.1.34, Apr 10, 2017
Author: <a href="http://88250.b3log.org">Liang Ding</a> Author: <a href="http://88250.b3log.org">Liang Ding</a>
Author: <a href="http://www.annpeter.cn">Ann Peter</a> Author: <a href="http://www.annpeter.cn">Ann Peter</a>
Author: <a href="http://vanessa.b3log.org">Vanessa</a> Author: <a href="http://vanessa.b3log.org">Vanessa</a>
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<artifactId>solo</artifactId> <artifactId>solo</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<name>Solo</name> <name>Solo</name>
<version>1.9.0</version> <version>2.0.0</version>
<description> <description>
A blogging system written in Java, feel free to create your or your team own blog. 一个用 Java 实现的博客系统,为你或你的团队创建个博客吧。 A blogging system written in Java, feel free to create your or your team own blog. 一个用 Java 实现的博客系统,为你或你的团队创建个博客吧。
</description> </description>
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<org.b3log.latke.version>2.3.11-SNAPSHOT</org.b3log.latke.version> <org.b3log.latke.version>2.3.10</org.b3log.latke.version>
<servlet.version>3.1.0</servlet.version> <servlet.version>3.1.0</servlet.version>
<slf4j.version>1.7.5</slf4j.version> <slf4j.version>1.7.5</slf4j.version>
......
...@@ -61,7 +61,7 @@ import java.util.Set; ...@@ -61,7 +61,7 @@ import java.util.Set;
* Solo Servlet listener. * Solo Servlet listener.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.9.2.19, Feb 20, 2017 * @version 1.9.2.20, Apr 10, 2017
* @since 0.3.1 * @since 0.3.1
*/ */
public final class SoloServletListener extends AbstractServletListener { public final class SoloServletListener extends AbstractServletListener {
...@@ -69,7 +69,7 @@ public final class SoloServletListener extends AbstractServletListener { ...@@ -69,7 +69,7 @@ public final class SoloServletListener extends AbstractServletListener {
/** /**
* Solo version. * Solo version.
*/ */
public static final String VERSION = "1.9.0"; public static final String VERSION = "2.0.0";
/** /**
* Logger. * Logger.
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package org.b3log.solo.service; package org.b3log.solo.service;
import org.b3log.latke.Keys; import org.b3log.latke.Keys;
import org.b3log.latke.Latkes;
import org.b3log.latke.ioc.inject.Inject; import org.b3log.latke.ioc.inject.Inject;
import org.b3log.latke.logging.Level; import org.b3log.latke.logging.Level;
import org.b3log.latke.logging.Logger; import org.b3log.latke.logging.Logger;
...@@ -24,6 +25,7 @@ import org.b3log.latke.mail.MailServiceFactory; ...@@ -24,6 +25,7 @@ import org.b3log.latke.mail.MailServiceFactory;
import org.b3log.latke.model.User; import org.b3log.latke.model.User;
import org.b3log.latke.repository.Query; import org.b3log.latke.repository.Query;
import org.b3log.latke.repository.Transaction; import org.b3log.latke.repository.Transaction;
import org.b3log.latke.repository.jdbc.util.Connections;
import org.b3log.latke.service.LangPropsService; import org.b3log.latke.service.LangPropsService;
import org.b3log.latke.service.ServiceException; import org.b3log.latke.service.ServiceException;
import org.b3log.latke.service.annotation.Service; import org.b3log.latke.service.annotation.Service;
...@@ -41,13 +43,15 @@ import org.json.JSONException; ...@@ -41,13 +43,15 @@ import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.IOException; import java.io.IOException;
import java.sql.Connection;
import java.sql.Statement;
/** /**
* Upgrade service. * Upgrade service.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="mailto:dongxu.wang@acm.org">Dongxu Wang</a> * @author <a href="mailto:dongxu.wang@acm.org">Dongxu Wang</a>
* @version 1.2.0.10, Feb 20, 2017 * @version 1.2.0.11, Apr 10, 2017
* @since 1.2.0 * @since 1.2.0
*/ */
@Service @Service
...@@ -57,68 +61,57 @@ public class UpgradeService { ...@@ -57,68 +61,57 @@ public class UpgradeService {
* Logger. * Logger.
*/ */
private static final Logger LOGGER = Logger.getLogger(UpgradeService.class); private static final Logger LOGGER = Logger.getLogger(UpgradeService.class);
/**
* Step for article updating.
*/
private static final int STEP = 50;
/**
* Mail Service.
*/
private static final MailService MAIL_SVC = MailServiceFactory.getMailService();
/**
* Old version.
*/
private static final String FROM_VER = "1.9.0";
/**
* New version.
*/
private static final String TO_VER = SoloServletListener.VERSION;
/**
* Whether the email has been sent.
*/
private static boolean sent = false;
/** /**
* Article repository. * Article repository.
*/ */
@Inject @Inject
private ArticleRepository articleRepository; private ArticleRepository articleRepository;
/** /**
* Comment repository. * Comment repository.
*/ */
@Inject @Inject
private CommentRepository commentRepository; private CommentRepository commentRepository;
/** /**
* User repository. * User repository.
*/ */
@Inject @Inject
private UserRepository userRepository; private UserRepository userRepository;
/** /**
* Option repository. * Option repository.
*/ */
@Inject @Inject
private OptionRepository optionRepository; private OptionRepository optionRepository;
/**
* Step for article updating.
*/
private static final int STEP = 50;
/** /**
* Preference Query Service. * Preference Query Service.
*/ */
@Inject @Inject
private PreferenceQueryService preferenceQueryService; private PreferenceQueryService preferenceQueryService;
/**
* Mail Service.
*/
private static final MailService MAIL_SVC = MailServiceFactory.getMailService();
/**
* Whether the email has been sent.
*/
private static boolean sent = false;
/** /**
* Language service. * Language service.
*/ */
@Inject @Inject
private LangPropsService langPropsService; private LangPropsService langPropsService;
/**
* Old version.
*/
private static final String FROM_VER = "1.8.0";
/**
* New version.
*/
private static final String TO_VER = SoloServletListener.VERSION;
/** /**
* Upgrades if need. * Upgrades if need.
*/ */
...@@ -130,7 +123,6 @@ public class UpgradeService { ...@@ -130,7 +123,6 @@ public class UpgradeService {
} }
final String currentVer = preference.getString(Option.ID_C_VERSION); final String currentVer = preference.getString(Option.ID_C_VERSION);
if (SoloServletListener.VERSION.equals(currentVer)) { if (SoloServletListener.VERSION.equals(currentVer)) {
return; return;
} }
...@@ -165,9 +157,34 @@ public class UpgradeService { ...@@ -165,9 +157,34 @@ public class UpgradeService {
private void perform() throws Exception { private void perform() throws Exception {
LOGGER.log(Level.INFO, "Upgrading from version [{0}] to version [{1}]....", FROM_VER, TO_VER); LOGGER.log(Level.INFO, "Upgrading from version [{0}] to version [{1}]....", FROM_VER, TO_VER);
Transaction transaction = optionRepository.beginTransaction(); Transaction transaction = null;
try { try {
final Connection connection = Connections.getConnection();
final Statement statement = connection.createStatement();
final String tablePrefix = Latkes.getLocalProperty("jdbc.tablePrefix") + "_";
statement.execute("CREATE TABLE `" + tablePrefix + "category` (\n" +
" `oId` varchar(19) NOT NULL,\n" +
" `categoryTitle` varchar(64) NOT NULL,\n" +
" `categoryURI` varchar(32) NOT NULL,\n" +
" `categoryDescription` text NOT NULL,\n" +
" `categoryOrder` int(11) NOT NULL,\n" +
" `categoryTagCnt` int(11) NOT NULL,\n" +
" PRIMARY KEY (`oId`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8;");
statement.execute("CREATE TABLE `" + tablePrefix + "category_tag` (\n" +
" `oId` varchar(19) NOT NULL,\n" +
" `category_oId` varchar(19) NOT NULL,\n" +
" `tag_oId` varchar(19) NOT NULL,\n" +
" PRIMARY KEY (`oId`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8;");
statement.close();
connection.commit();
connection.close();
transaction = optionRepository.beginTransaction();
final JSONObject versionOpt = optionRepository.get(Option.ID_C_VERSION); final JSONObject versionOpt = optionRepository.get(Option.ID_C_VERSION);
versionOpt.put(Option.OPTION_VALUE, TO_VER); versionOpt.put(Option.OPTION_VALUE, TO_VER);
optionRepository.update(Option.ID_C_VERSION, versionOpt); optionRepository.update(Option.ID_C_VERSION, versionOpt);
......
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