Commit 6145c23b authored by Liang Ding's avatar Liang Ding

修改版本到 0.6.1

parent 56c16af3
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
Description: B3log Solo core. Description: B3log Solo core.
Version: 2.0.1.3, Apr 26, 2013 Version: 2.0.1.4, Aug 20, 2013
Author: Liang Ding Author: Liang Ding
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<parent> <parent>
<groupId>org.b3log</groupId> <groupId>org.b3log</groupId>
<artifactId>solo</artifactId> <artifactId>solo</artifactId>
<version>0.6.0</version> <version>0.6.1</version>
</parent> </parent>
<dependencies> <dependencies>
......
...@@ -59,7 +59,7 @@ import org.json.JSONObject; ...@@ -59,7 +59,7 @@ import org.json.JSONObject;
* B3log Solo servlet listener. * B3log 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.1.0.0, Jun 28, 2013 * @version 1.1.0.1, Aug 20, 2013
* @since 0.3.1 * @since 0.3.1
*/ */
public final class SoloServletListener extends AbstractServletListener { public final class SoloServletListener extends AbstractServletListener {
...@@ -67,7 +67,7 @@ public final class SoloServletListener extends AbstractServletListener { ...@@ -67,7 +67,7 @@ public final class SoloServletListener extends AbstractServletListener {
/** /**
* B3log Solo version. * B3log Solo version.
*/ */
public static final String VERSION = "0.6.0"; public static final String VERSION = "0.6.1";
/** /**
* Logger. * Logger.
......
...@@ -18,10 +18,7 @@ package org.b3log.solo.processor; ...@@ -18,10 +18,7 @@ package org.b3log.solo.processor;
import java.io.IOException; import java.io.IOException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.util.List;
import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
import org.b3log.latke.Keys; import org.b3log.latke.Keys;
import org.b3log.latke.Latkes; import org.b3log.latke.Latkes;
...@@ -32,10 +29,7 @@ import org.b3log.latke.mail.MailService; ...@@ -32,10 +29,7 @@ import org.b3log.latke.mail.MailService;
import org.b3log.latke.mail.MailServiceFactory; import org.b3log.latke.mail.MailServiceFactory;
import org.b3log.latke.model.User; import org.b3log.latke.model.User;
import org.b3log.latke.repository.*; import org.b3log.latke.repository.*;
import org.b3log.latke.repository.jdbc.JdbcFactory;
import org.b3log.latke.repository.jdbc.util.Connections; import org.b3log.latke.repository.jdbc.util.Connections;
import org.b3log.latke.repository.jdbc.util.FieldDefinition;
import org.b3log.latke.repository.jdbc.util.JdbcRepositories;
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.servlet.HTTPRequestContext; import org.b3log.latke.servlet.HTTPRequestContext;
...@@ -58,12 +52,10 @@ import org.json.JSONObject; ...@@ -58,12 +52,10 @@ import org.json.JSONObject;
* *
* @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.1.1.9, Apr 26, 2013 * @version 1.1.1.10, Aug 20, 2013
* @since 0.3.1 * @since 0.3.1
*/ */
@RequestProcessor @RequestProcessor
// TODO:
// 1. Removes preference.blogHost from repository
public class UpgradeProcessor { public class UpgradeProcessor {
/** /**
...@@ -116,6 +108,16 @@ public class UpgradeProcessor { ...@@ -116,6 +108,16 @@ public class UpgradeProcessor {
@Inject @Inject
private LangPropsService langPropsService; private LangPropsService langPropsService;
/**
* Old version.
*/
private static final String FROM_VER = "0.6.0";
/**
* New version.
*/
private static final String TO_VER = SoloServletListener.VERSION;
/** /**
* Checks upgrade. * Checks upgrade.
* *
...@@ -139,22 +141,25 @@ public class UpgradeProcessor { ...@@ -139,22 +141,25 @@ public class UpgradeProcessor {
renderer.setContent("Upgrade successfully ;-)"); renderer.setContent("Upgrade successfully ;-)");
final String version = preference.getString(Preference.VERSION); final String currentVer = preference.getString(Preference.VERSION);
if (SoloServletListener.VERSION.equals(version)) { if (SoloServletListener.VERSION.equals(currentVer)) {
return; return;
} }
if ("0.5.6".equals(version)) { if (FROM_VER.equals(currentVer)) {
v056ToV060(); upgrade();
} else {
LOGGER.log(Level.WARN, "Attempt to skip more than one version to upgrade. Expected: 0.5.6; Actually: {0}", version); return;
if (!sent) { }
notifyUserByEmail();
sent = true; LOGGER.log(Level.WARN, "Attempt to skip more than one version to upgrade. Expected: {0}; Actually: {1}", FROM_VER, currentVer);
} if (!sent) {
renderer.setContent(langPropsService.get("skipVersionAlert")); notifyUserByEmail();
sent = true;
} }
renderer.setContent(langPropsService.get("skipVersionAlert"));
} catch (final Exception e) { } catch (final Exception e) {
LOGGER.log(Level.ERROR, e.getMessage(), e); LOGGER.log(Level.ERROR, e.getMessage(), e);
renderer.setContent( renderer.setContent(
...@@ -165,15 +170,14 @@ public class UpgradeProcessor { ...@@ -165,15 +170,14 @@ public class UpgradeProcessor {
} }
/** /**
* Upgrades from version 056 to version 060. * Upgrades.
* *
* @throws Exception upgrade fails * @throws Exception upgrade fails
*/ */
private void v056ToV060() throws Exception { private void upgrade() throws Exception {
LOGGER.info("Upgrading from version 056 to version 060...."); LOGGER.log(Level.INFO, "Upgrading from version [{0}] to version [{1}]....", FROM_VER, TO_VER);
articleRepository.setCacheEnabled(false); articleRepository.setCacheEnabled(false);
Transaction transaction = null; Transaction transaction = null;
try { try {
...@@ -186,50 +190,34 @@ public class UpgradeProcessor { ...@@ -186,50 +190,34 @@ public class UpgradeProcessor {
final Statement statement = connection.createStatement(); final Statement statement = connection.createStatement();
final String tablePrefix = Latkes.getLocalProperty("jdbc.tablePrefix"); final String tablePrefix = Latkes.getLocalProperty("jdbc.tablePrefix");
final String tableName = Strings.isEmptyOrNull(tablePrefix) ? "preference" : tablePrefix + "_preference";
String tableName = Strings.isEmptyOrNull(tablePrefix) ? "preference" : tablePrefix + "_preference"; statement.execute("ALTER TABLE " + tableName + " DROP COLUMN blogHost");
statement.execute("ALTER TABLE " + tableName + " ADD feedOutputCnt int");
tableName = Strings.isEmptyOrNull(tablePrefix) ? "user" : tablePrefix + "_user";
statement.execute("ALTER TABLE " + tableName + " ADD userURL varchar(255)");
connection.commit(); connection.commit();
tableName = Strings.isEmptyOrNull(tablePrefix) ? "option" : tablePrefix + "_option";
final Map<String, List<FieldDefinition>> map = JdbcRepositories.getRepositoriesMap();
try {
JdbcFactory.createJdbcFactory().createTable(tableName, map.get(tableName));
} catch (final SQLException e) {
LOGGER.log(Level.ERROR, "createTable[" + tableName + "] error", e);
}
} }
// Upgrades preference model // Upgrades preference model
final JSONObject preference = preferenceRepository.get(Preference.PREFERENCE); final JSONObject preference = preferenceRepository.get(Preference.PREFERENCE);
preference.put(Preference.VERSION, "0.6.0"); preference.put(Preference.VERSION, TO_VER);
preference.put(Preference.FEED_OUTPUT_CNT, Preference.Default.DEFAULT_FEED_OUTPUT_CNT);
preferenceRepository.update(Preference.PREFERENCE, preference); preferenceRepository.update(Preference.PREFERENCE, preference);
upgradeUsers();
transaction.commit(); transaction.commit();
LOGGER.log(Level.TRACE, "Updated preference"); LOGGER.log(Level.TRACE, "Updated preference");
} catch (final Exception e) { } catch (final Exception e) {
if (transaction.isActive()) { if (null != transaction && transaction.isActive()) {
transaction.rollback(); transaction.rollback();
} }
LOGGER.log(Level.ERROR, "Upgrade failed.", e); LOGGER.log(Level.ERROR, "Upgrade failed!", e);
throw new Exception("Upgrade failed from version 056 to version 060"); throw new Exception("Upgrade failed from version [" + FROM_VER + "] to version [" + TO_VER + ']');
} finally { } finally {
articleRepository.setCacheEnabled(true); articleRepository.setCacheEnabled(true);
} }
LOGGER.info("Upgraded from version 056 to version 060 successfully :-)"); LOGGER.log(Level.INFO, "Upgraded from version [{0}] to version [{1}] successfully :-)", FROM_VER, TO_VER);
} }
/** /**
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
Description: B3log Solo parent POM. Description: B3log Solo parent POM.
Version: 2.0.3.1, Jul 4, 2013 Version: 2.0.3.2, Aug 20, 2013
Author: Liang Ding Author: Liang Ding
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<groupId>org.b3log</groupId> <groupId>org.b3log</groupId>
<artifactId>solo</artifactId> <artifactId>solo</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>0.6.0</version> <version>0.6.1</version>
<name>B3log Solo</name> <name>B3log Solo</name>
<url>https://github.com/b3log/b3log-solo</url> <url>https://github.com/b3log/b3log-solo</url>
<description> <description>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
Description: B3log Solo BAE POM. Description: B3log Solo BAE POM.
Version: 1.0.1.3, Mar 8, 2013 Version: 1.0.1.4, Aug 20, 2013
Author: Liang Ding Author: Liang Ding
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<parent> <parent>
<groupId>org.b3log</groupId> <groupId>org.b3log</groupId>
<artifactId>solo-war</artifactId> <artifactId>solo-war</artifactId>
<version>0.6.0</version> <version>0.6.1</version>
</parent> </parent>
<properties> <properties>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
Description: B3log Solo GAE POM. Description: B3log Solo GAE POM.
Version: 2.0.2.2, Jan 4, 2013 Version: 2.0.2.3, Aug 20, 2013
Author: Liang Ding Author: Liang Ding
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<parent> <parent>
<groupId>org.b3log</groupId> <groupId>org.b3log</groupId>
<artifactId>solo-war</artifactId> <artifactId>solo-war</artifactId>
<version>0.6.0</version> <version>0.6.1</version>
</parent> </parent>
<properties> <properties>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
Description: B3log Solo (H2) standard Servlet container POM. Description: B3log Solo (H2) standard Servlet container POM.
Version: 1.0.0.1, Jan 4, 2013 Version: 1.0.0.2, Aug 20, 2013
Author: Liang Ding Author: Liang Ding
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<parent> <parent>
<groupId>org.b3log</groupId> <groupId>org.b3log</groupId>
<artifactId>solo-war</artifactId> <artifactId>solo-war</artifactId>
<version>0.6.0</version> <version>0.6.1</version>
</parent> </parent>
<properties> <properties>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
Description: B3log Solo (MySQL) standard Servlet container POM. Description: B3log Solo (MySQL) standard Servlet container POM.
Version: 1.0.1.2, Jan 4, 2013 Version: 1.0.1.3, Aug 20, 2013
Author: Liang Ding Author: Liang Ding
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<parent> <parent>
<groupId>org.b3log</groupId> <groupId>org.b3log</groupId>
<artifactId>solo-war</artifactId> <artifactId>solo-war</artifactId>
<version>0.6.0</version> <version>0.6.1</version>
</parent> </parent>
<properties> <properties>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
Description: B3log Solo WAR POM. Description: B3log Solo WAR POM.
Version: 2.0.1.6, Dec 27, 2012 Version: 2.0.1.7, Aug 20, 2013
Author: Liang Ding Author: Liang Ding
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<parent> <parent>
<groupId>org.b3log</groupId> <groupId>org.b3log</groupId>
<artifactId>solo</artifactId> <artifactId>solo</artifactId>
<version>0.6.0</version> <version>0.6.1</version>
</parent> </parent>
<modules> <modules>
......
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