You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by so...@apache.org on 2019/07/04 06:42:28 UTC
[openmeetings] branch master updated: [OPENMEETINGS-2080]
serverTimezone parameter is added to MySql connection URL
This is an automated email from the ASF dual-hosted git repository.
solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openmeetings.git
The following commit(s) were added to refs/heads/master by this push:
new 2a7ad4b [OPENMEETINGS-2080] serverTimezone parameter is added to MySql connection URL
2a7ad4b is described below
commit 2a7ad4bdc2afb2312d2862af0cdf005bcf2bfad5
Author: Maxim Solodovnik <so...@gmail.com>
AuthorDate: Thu Jul 4 13:42:16 2019 +0700
[OPENMEETINGS-2080] serverTimezone parameter is added to MySql connection URL
---
.../org/apache/openmeetings/cli/MysqlPatcher.java | 23 +++++++--
openmeetings-server/src/site/xdoc/MySQLConfig.xml | 31 +++++------
.../org/apache/openmeetings/cli/TestPatcher.java | 60 ++++++++++++++++++++++
3 files changed, 92 insertions(+), 22 deletions(-)
diff --git a/openmeetings-install/src/main/java/org/apache/openmeetings/cli/MysqlPatcher.java b/openmeetings-install/src/main/java/org/apache/openmeetings/cli/MysqlPatcher.java
index 15977de..844ccb3 100644
--- a/openmeetings-install/src/main/java/org/apache/openmeetings/cli/MysqlPatcher.java
+++ b/openmeetings-install/src/main/java/org/apache/openmeetings/cli/MysqlPatcher.java
@@ -18,12 +18,27 @@
*/
package org.apache.openmeetings.cli;
+import java.util.TimeZone;
+
+import org.apache.wicket.request.Url;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.apache.wicket.request.mapper.parameter.PageParametersEncoder;
+import org.apache.wicket.util.string.StringValue;
+
public class MysqlPatcher extends ConnectionPropertiesPatcher {
+ static final String TZ_PARAM = "serverTimezone";
+
@Override
protected String getUrl(String inUrl, String host, String inPort, String inDb) {
- String port = (inPort == null) ? "3306" : inPort;
- String db = (inDb == null) ? DEFAULT_DB_NAME : inDb;
- String suffix = inUrl.substring(inUrl.indexOf('?'));
- return String.format("jdbc:mysql://%s:%s/%s%s", host, port, db, suffix);
+ Url url = Url.parse(inUrl);
+ url.setHost(host);
+ url.setPort((inPort == null) ? 3306 : Integer.valueOf(inPort));
+ url.getSegments().set(1, (inDb == null) ? DEFAULT_DB_NAME : inDb);
+ PageParameters pp = new PageParametersEncoder().decodePageParameters(url);
+ StringValue tz = pp.get(TZ_PARAM);
+ if (tz.isEmpty()) {
+ url.setQueryParameter(TZ_PARAM, TimeZone.getDefault().getID());
+ }
+ return url.toString(Url.StringMode.FULL);
}
}
diff --git a/openmeetings-server/src/site/xdoc/MySQLConfig.xml b/openmeetings-server/src/site/xdoc/MySQLConfig.xml
index 7c71949..5cd3680 100644
--- a/openmeetings-server/src/site/xdoc/MySQLConfig.xml
+++ b/openmeetings-server/src/site/xdoc/MySQLConfig.xml
@@ -13,16 +13,14 @@
limitations under the License.
-->
<document xmlns="http://maven.apache.org/XDOC/2.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
<properties>
<title>MySQL Configuration</title>
<author email="dev@openmeetings.apache.org">Apache OpenMeetings Team</author>
</properties>
-
<body>
<section name="MySQL Configuration">
-
<subsection name="Before you start">
<ul>
<li>Make sure that you have set utf8 as
@@ -41,36 +39,33 @@
</li>
</ul>
</subsection>
-
<subsection name="Steps todo">
<ul>
<li>
- You need to download the JConnector from mysql
- <a href="http://www.mysql.com/downloads/connector/j/" target="_blank"
- rel="nofollow">http://www.mysql.com/downloads/connector/j/</a>
+ You need to download the JConnector from Maven central
+ <a href="https://mvnrepository.com/artifact/mysql/mysql-connector-java" target="_blank"
+ rel="nofollow">https://mvnrepository.com/artifact/mysql/mysql-connector-java</a>
and place it into:
<tt>$OM_HOME/webapps/openmeetings/WEB-INF/lib/</tt>
</li>
<li>
Run OpenMeetings and goto the web-based installer:
- http://localhost:5080/openmeetings/install
+ <tt>http://localhost:5080/openmeetings/install</tt><br/>
+ Or <a href="./CommandLineAdmin.html" target="_blank"
+ rel="nofollow">Command line installer</a>
+ </li>
+ <li>After installation is complete please make sure additional parameter <tt>serverTimezone=</tt> was added
+ to the connection string.
</li>
</ul>
</subsection>
-
<subsection name="MySQL Sample Configuration">
<p>
- There is a sample configuration for MySQL that ships with
- every
- release in:
+ There is a sample configuration for MySQL that ships with every release in:
<br />
- /webapps/openmeetings/WEB-INF/classes/META-INF/mysql_persistence.xml
+ <tt>/webapps/openmeetings/WEB-INF/classes/META-INF/mysql_persistence.xml</tt>
</p>
</subsection>
-
-
</section>
-
</body>
-
</document>
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/cli/TestPatcher.java b/openmeetings-web/src/test/java/org/apache/openmeetings/cli/TestPatcher.java
new file mode 100644
index 0000000..a915688
--- /dev/null
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/cli/TestPatcher.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.openmeetings.cli;
+
+import static org.apache.openmeetings.AbstractSpringTest.setOmHome;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.TimeZone;
+
+import org.apache.openmeetings.util.ConnectionProperties;
+import org.apache.openmeetings.util.ConnectionProperties.DbType;
+import org.apache.wicket.request.Url;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.apache.wicket.request.mapper.parameter.PageParametersEncoder;
+import org.apache.wicket.util.string.StringValue;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+public class TestPatcher {
+ private static final String HOST = "myhost";
+ private static final String PORT = "6666";
+ private static final String DB = "mydb";
+ private static final String USER = "myuser";
+ private static final String PASS = "mypass";
+
+ @BeforeEach
+ public void setUp() {
+ setOmHome();
+ }
+
+ @Test
+ public void test() throws Exception {
+ for (DbType dbType : DbType.values()) {
+ ConnectionProperties props = ConnectionPropertiesPatcher.patch(dbType.name(), HOST, PORT, DB, USER, PASS);
+ assertEquals(dbType, props.getDbType(), "DB type should match");
+ if (DbType.mysql == dbType) {
+ Url url = Url.parse(props.getURL());
+ PageParameters pp = new PageParametersEncoder().decodePageParameters(url);
+ StringValue tz = pp.get("serverTimezone");
+ assertEquals(TimeZone.getDefault().getID(), tz.toString(), "serverTimezone parameter is mandatory for MySql");
+ }
+ }
+ }
+}