You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ss...@apache.org on 2013/10/03 17:07:15 UTC
[16/22] git commit: MARMOTTA-85: move KiWi database configuration to
KiWi backend
MARMOTTA-85: move KiWi database configuration to KiWi backend
Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/d26c9a5c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/d26c9a5c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/d26c9a5c
Branch: refs/heads/develop
Commit: d26c9a5c09fb25d338886223b3c214fad9a79a99
Parents: 18ced91
Author: Sebastian Schaffert <ss...@apache.org>
Authored: Thu Oct 3 15:13:54 2013 +0200
Committer: Sebastian Schaffert <ss...@apache.org>
Committed: Thu Oct 3 15:13:54 2013 +0200
----------------------------------------------------------------------
.../backend/bigdata/BigDataStoreProvider.java | 11 -
.../src/main/resources/kiwi-module.properties | 38 +++
.../backend/kiwi/DatabaseWebService.java | 109 +++++++
.../main/resources/config-defaults.properties | 67 ++++
.../resources/config-descriptions.properties | 53 ++++
.../src/main/resources/kiwi-module.properties | 41 +++
.../src/main/resources/web/admin/about.html | 62 ++++
.../main/resources/web/admin/configuration.html | 46 +++
.../src/main/resources/web/admin/database.html | 37 +++
.../resources/web/admin/js/widgets/database.js | 303 +++++++++++++++++++
.../src/main/resources/kiwi-module.properties | 41 +++
.../webservices/system/SystemWebService.java | 64 ----
.../src/main/resources/kiwi-module.properties | 3 -
.../src/main/resources/web/admin/database.html | 37 ---
.../resources/web/admin/js/widgets/database.js | 303 -------------------
15 files changed, 797 insertions(+), 418 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d26c9a5c/platform/marmotta-backend-bigdata/src/main/java/org/apache/marmotta/platform/backend/bigdata/BigDataStoreProvider.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-backend-bigdata/src/main/java/org/apache/marmotta/platform/backend/bigdata/BigDataStoreProvider.java b/platform/marmotta-backend-bigdata/src/main/java/org/apache/marmotta/platform/backend/bigdata/BigDataStoreProvider.java
index 4a1c173..c26bbaa 100644
--- a/platform/marmotta-backend-bigdata/src/main/java/org/apache/marmotta/platform/backend/bigdata/BigDataStoreProvider.java
+++ b/platform/marmotta-backend-bigdata/src/main/java/org/apache/marmotta/platform/backend/bigdata/BigDataStoreProvider.java
@@ -86,17 +86,6 @@ public class BigDataStoreProvider implements StoreProvider {
@Override
public SailRepository createRepository(Sail sail) {
return new BigDataSesame27Repository(sail);
-
- /*
- if(sail instanceof BigDataSesame27Sail) {
- log.info("no additional sails in stack; native SPARQL support enabled");
- // direct access to underlying sail, no other sails stacked inbetween
- return new BigdataSailRepository(((BigDataSesame27Sail) sail).getWrapped());
- } else {
- log.warn("bigdata backend currently does not support stacked sails, native SPARQL support disabled");
- return new SailRepository(sail);
- }
- */
}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d26c9a5c/platform/marmotta-backend-bigdata/src/main/resources/kiwi-module.properties
----------------------------------------------------------------------
diff --git a/platform/marmotta-backend-bigdata/src/main/resources/kiwi-module.properties b/platform/marmotta-backend-bigdata/src/main/resources/kiwi-module.properties
new file mode 100644
index 0000000..833473d
--- /dev/null
+++ b/platform/marmotta-backend-bigdata/src/main/resources/kiwi-module.properties
@@ -0,0 +1,38 @@
+#
+# 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.
+#
+
+name=Storage Backend: BigData
+
+container=Generic
+container.weight = 10
+
+subtitle = Configure BigData Backend
+weight = 10
+
+icon_small = /admin/img/config_small.png
+
+#do not change!!!
+baseurl=/storage-bigdata
+
+adminpage.0.title=About
+adminpage.0.link=/admin/about.html
+
+adminpage.1.title=Configuration
+adminpage.1.link=/admin/configuration.html
+
+webservices=
+
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d26c9a5c/platform/marmotta-backend-kiwi/src/main/java/org/apache/marmotta/platform/backend/kiwi/DatabaseWebService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-backend-kiwi/src/main/java/org/apache/marmotta/platform/backend/kiwi/DatabaseWebService.java b/platform/marmotta-backend-kiwi/src/main/java/org/apache/marmotta/platform/backend/kiwi/DatabaseWebService.java
new file mode 100644
index 0000000..8c68a96
--- /dev/null
+++ b/platform/marmotta-backend-kiwi/src/main/java/org/apache/marmotta/platform/backend/kiwi/DatabaseWebService.java
@@ -0,0 +1,109 @@
+/*
+ * 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.marmotta.platform.backend.kiwi;
+
+import org.apache.marmotta.platform.core.api.config.ConfigurationService;
+import org.apache.marmotta.platform.core.api.triplestore.SesameService;
+import org.apache.marmotta.platform.core.jaxrs.ErrorResponse;
+import org.slf4j.Logger;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Response;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+@Path("/storage-kiwi")
+@ApplicationScoped
+public class DatabaseWebService {
+
+
+ @Inject
+ private Logger log;
+
+ @Inject
+ private ConfigurationService configurationService;
+
+ @Inject
+ private SesameService sesameService;
+
+
+ @POST
+ @Path("/ping")
+ public Response pingDatabase(@QueryParam("type")String type,@QueryParam("url")String url,@QueryParam("user")String user,@QueryParam("pwd")String pwd) {
+ if(type==null||url==null||user==null||pwd==null) {
+ return Response.status(400).entity("one or more values are not defined").build();
+ }
+
+ //get driver
+ String db_driver = configurationService.getStringConfiguration("database."+type+".driver");
+ if(db_driver==null) {
+ return ErrorResponse.errorResponse(Response.Status.INTERNAL_SERVER_ERROR, "driver for " + type + " not defined");
+ }
+
+ //try if type matches url
+ if(!url.startsWith("jdbc:"+type)) {
+ return ErrorResponse.errorResponse(Response.Status.INTERNAL_SERVER_ERROR,"database and url do not match properly");
+ }
+
+ //try to connect
+ try {
+ Class.forName(db_driver);
+ Connection conn = DriverManager.getConnection(url, user, pwd);
+ conn.close();
+ return Response.ok().build();
+ } catch (ClassNotFoundException e) {
+ return ErrorResponse.errorResponse(Response.Status.INTERNAL_SERVER_ERROR,"Can't load driver ",e);
+ } catch (SQLException e) {
+ return ErrorResponse.errorResponse(Response.Status.INTERNAL_SERVER_ERROR,"Database access failed ",e);
+ }
+ }
+
+ /**
+ * Manually trigger the garbage collector.
+ *
+ * @return ok if successful, 500 if not
+ * @HTTP 200 if garbage collection completed successfully
+ * @HTTP 500 if there was an error while running garbage collection (see log)
+ */
+ @POST
+ @Path("/gc")
+ public Response garbageCollector() {
+ log.info("Running triple store garbage collection after admin user request ...");
+ try {
+ sesameService.garbageCollect();
+
+ return Response.ok().entity("garbage collection completed successfully").build();
+ } catch(Exception ex) {
+ log.error("Error while running garbage collection ...",ex);
+ return ErrorResponse.errorResponse(Response.Status.INTERNAL_SERVER_ERROR, ex);
+ }
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d26c9a5c/platform/marmotta-backend-kiwi/src/main/resources/config-defaults.properties
----------------------------------------------------------------------
diff --git a/platform/marmotta-backend-kiwi/src/main/resources/config-defaults.properties b/platform/marmotta-backend-kiwi/src/main/resources/config-defaults.properties
new file mode 100644
index 0000000..4f04391
--- /dev/null
+++ b/platform/marmotta-backend-kiwi/src/main/resources/config-defaults.properties
@@ -0,0 +1,67 @@
+#
+# 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.
+#
+
+
+###############################################################################
+# KiWi database configuration
+###############################################################################
+
+# the database type (h2, postgres or mysql)
+database.type = h2
+
+# the URL to access the database
+database.url =
+
+# the database user
+database.user =
+
+# the database password
+database.password =
+
+# the database mode (create, update or validate)
+database.mode =
+
+# report slow queries in the log (not thread safe)
+database.debug.slowqueries = false
+
+
+# turn on batch commits for database transactions (EXPERIMENTAL); if supported by the database backend, this can
+# lead to considerable performance improvements
+database.batchcommit = true
+
+# the maximum size of a batch before it is committed to the database; only applicable if batchcommit is enabled
+database.batchsize = 10000
+
+# generator to use for creating database IDs; possible values are uuid-time, uuid-random, sequence, memory, snowflake
+database.generator = snowflake
+
+# Hibernate-specific configuration for H2
+database.h2.driver = org.h2.Driver
+database.h2.url = jdbc:h2:/tmp/kiwi/db/kiwi;MVCC=true;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=10
+
+# Hibernate-specific configuration for PostgreSQL
+database.postgres.driver = org.postgresql.Driver
+database.postgres.url = jdbc:postgresql://localhost:5432/lmf?prepareThreshold=3
+
+# Hibernate-specific configuration for MySQL
+database.mysql.driver = com.mysql.jdbc.Driver
+database.mysql.url = jdbc:mysql://localhost:3306/lmf?useUnicode=true&characterEncoding=UTF-8&rewriteBatchedStatements=true
+
+# Hibernate-specific configuration for Oracle
+database.oracle.url = jdbc:oracle:thin:@//localhost:1521/XE
+database.oracle.driver = oracle.jdbc.OracleDriver
+
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d26c9a5c/platform/marmotta-backend-kiwi/src/main/resources/config-descriptions.properties
----------------------------------------------------------------------
diff --git a/platform/marmotta-backend-kiwi/src/main/resources/config-descriptions.properties b/platform/marmotta-backend-kiwi/src/main/resources/config-descriptions.properties
new file mode 100644
index 0000000..37493c0
--- /dev/null
+++ b/platform/marmotta-backend-kiwi/src/main/resources/config-descriptions.properties
@@ -0,0 +1,53 @@
+#
+# 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.
+#
+
+###############################################################################
+# LMF database configuration
+###############################################################################
+
+database.type.description = the database type (h2, postgres or mysql)
+database.type.type = java.lang.Enum("h2"|"postgres"|"mysql"|"oracle")
+
+database.url.description = the URL to access the database
+database.url.type = java.net.URL
+
+database.user.description = the database user
+database.user.type = java.lang.String
+
+database.password.description = the database password
+database.password.type = java.lang.String("password")
+
+database.mode.description = the database mode (create, update, validate or off)
+database.mode.type = java.lang.Enum("create"|"update"|"validate"|"off")
+
+database.debug.slowqueries.description = enable reporting of slow database queries (produces additional overhead and is not thread safe)
+database.debug.slowqueries.type = java.lang.Boolean
+
+database.batchcommit.description = turn on batch commits for database transactions (EXPERIMENTAL); if supported by the \
+ database backend, this can lead to considerable performance improvements
+database.batchcommit.type = java.lang.Boolean
+
+database.batchsize.description = the maximum size of a batch before it is committed to the database; only applicable if \
+ batchcommit is enabled
+database.batchsize.type = java.lang.Integer(10|0|*)
+
+database.generator.description = generator for creating database identifiers; uuid-time creates unique identifiers based \
+ on time and machine, uuid-random creates random identifiers, sequence uses a database sequence, memory loads a database \
+ sequence and increments in-memory (fast but requires exclusive database access), snowflake uses the Twitter Snowflake \
+ algorithm (fast and reliable)
+database.generator.type = java.lang.Enum("uuid-time"|"uuid-random"|"sequence"|"memory"|"snowflake")
+
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d26c9a5c/platform/marmotta-backend-kiwi/src/main/resources/kiwi-module.properties
----------------------------------------------------------------------
diff --git a/platform/marmotta-backend-kiwi/src/main/resources/kiwi-module.properties b/platform/marmotta-backend-kiwi/src/main/resources/kiwi-module.properties
new file mode 100644
index 0000000..de7f308
--- /dev/null
+++ b/platform/marmotta-backend-kiwi/src/main/resources/kiwi-module.properties
@@ -0,0 +1,41 @@
+#
+# 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.
+#
+
+name=Storage Backend: KiWi
+
+container=Generic
+container.weight = 10
+
+subtitle = Configure KiWi Backend
+weight = 10
+
+icon_small = /admin/img/config_small.png
+
+#do not change!!!
+baseurl=/storage-kiwi
+
+adminpage.0.title=About
+adminpage.0.link=/admin/about.html
+
+adminpage.1.title=Configuration
+adminpage.1.link=/admin/configuration.html
+
+adminpage.2.title=Database
+adminpage.2.link=/admin/database.html
+
+webservices=org.apache.marmotta.platform.backend.kiwi.DatabaseWebService
+
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d26c9a5c/platform/marmotta-backend-kiwi/src/main/resources/web/admin/about.html
----------------------------------------------------------------------
diff --git a/platform/marmotta-backend-kiwi/src/main/resources/web/admin/about.html b/platform/marmotta-backend-kiwi/src/main/resources/web/admin/about.html
new file mode 100644
index 0000000..706bfda
--- /dev/null
+++ b/platform/marmotta-backend-kiwi/src/main/resources/web/admin/about.html
@@ -0,0 +1,62 @@
+<!--
+
+ 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.
+
+-->
+<html>
+<head>
+ <!--###BEGIN_HEAD###-->
+ <title>Core Module</title>
+ <!--###END_HEAD###-->
+</head>
+<body>
+<!--###BEGIN_CONTENT###-->
+<h1>Apache Marmotta</h1>
+<h2>
+ An Open Platform for Linked Data
+</h2>
+<p>The goal of Apache Marmotta is to provide an open implementation of a Linked Data Platform that can be used, extended, and deployed easily by organizations who want to publish Linked Data or build custom applications on Linked Data.</p>
+<p>You can find more information about the project and the supported features on <a href="http://marmotta.incubator.apache.org/">http://marmotta.incubator.apache.org</a>.</p>
+<h2>
+ Links to common features
+</h2>
+<p>You can find all installed features on the module list on the right side. To get a quick access to common functionalities, we listed some links:</p>
+<ul>
+ <li><a href="import.html">Import your data:</a> RDF and non-RDF formats are supported.</li>
+ <li><a href="../../sparql/admin/snorql.html">SPARQL your data:</a> full SPARQL 1.1 support including querying and updates.</li>
+ <li><a href="configuration.html">Configure your database:</a> Marmotta comes with h2 embedded; configure your own database to handle bigger data.</li>
+ <li><a href="dataview.html">Control your data:</a> the dataview gives an overview on the current data in the system. (Attention: there might be problems with the visualisation if big data sets).</li>
+ <li><a href="../../user/admin/users.html">Manage your user accounts:</a> the user module allows creating and managing user accounts.</li>
+ <li><a href="tasks.html">Inspect your tasks:</a> check the status of the running tasks.</li>
+</ul>
+
+<h2>Marmotta Modules</h2>
+<p>Apache Marmotta provides some modules:</p>
+<dl>
+ <dt><a href="../../core/admin/about.html">Core</a></dt> <dd>provides the core RDF and Linked Data Platform capabilities.</dd>
+ <dt><a href="../../sparql/admin/about.html">SPARQL</a></dt> <dd>offers query capabilities for the triplestore.</dd>
+ <dt><a href="../../ldpath/admin/about.html">LDPath Querying</a></dt> <dd>provides support for LDPath within the platform.</dd>
+ <dt><a href="../../cache/admin/about.html">Linked Data Caching</a></dt> <dd>provides transparent mechanism to cache Web resources.</dd>
+ <dt><a href="../../reasoner/admin/about.html">Reasoner</a></dt> <dd>adds a rule-based reasoner to the triple store.</dd>
+ <dt><a href="../../security/admin/about.html">Security</a></dt> <dd>implements security mechanism.</dd>
+ <dt><a href="../../user/me.html">User</a></dt> <dd>provides the user management features.</dd>
+ <dt><a href="../../versioning/admin/about.html">Versioning</a></dt> <dd>offers versioning services on top of the triple store.</dd>
+</dl>
+<!--###END_CONTENT###-->
+</body>
+</html>
+
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d26c9a5c/platform/marmotta-backend-kiwi/src/main/resources/web/admin/configuration.html
----------------------------------------------------------------------
diff --git a/platform/marmotta-backend-kiwi/src/main/resources/web/admin/configuration.html b/platform/marmotta-backend-kiwi/src/main/resources/web/admin/configuration.html
new file mode 100644
index 0000000..af9961f
--- /dev/null
+++ b/platform/marmotta-backend-kiwi/src/main/resources/web/admin/configuration.html
@@ -0,0 +1,46 @@
+<!--
+ ~ 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.
+ -->
+<html>
+<head>
+<!--###BEGIN_HEAD###-->
+ <title>Core Module Configuration</title>
+ <link type="text/css" rel="stylesheet" href="../public/js/widgets/configurator/style.css">
+ <script type="text/javascript" src="../../webjars/jquery/1.8.2/jquery.min.js"></script>
+ <script type="text/javascript" src="js/widgets/database.js"></script>
+ <script type="text/javascript">
+ jQuery(document).ready(function(){
+ $('#lmf_database').lmf_database({host:_SERVER_URL});
+ });
+ </script>
+<!--###END_HEAD###-->
+</head>
+<body>
+<div id="main">
+<div id="contents">
+<!--###BEGIN_CONTENT###-->
+<h1>KiWi Storage Backend Configuration</h1>
+ <p>
+ Here you can configure the database options for the Marmotta KiWi Storage Backend.<br/>
+ </p>
+ <div id="lmf_database">
+ <h4>Loading database manager</h4>
+ </div>
+<!--###END_CONTENT###-->
+</div>
+</div>
+</body>
+</html>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d26c9a5c/platform/marmotta-backend-kiwi/src/main/resources/web/admin/database.html
----------------------------------------------------------------------
diff --git a/platform/marmotta-backend-kiwi/src/main/resources/web/admin/database.html b/platform/marmotta-backend-kiwi/src/main/resources/web/admin/database.html
new file mode 100644
index 0000000..87b6835
--- /dev/null
+++ b/platform/marmotta-backend-kiwi/src/main/resources/web/admin/database.html
@@ -0,0 +1,37 @@
+<!--
+
+ 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.
+
+-->
+<html>
+<head>
+ <!--###BEGIN_HEAD###-->
+ <title>Core Module</title>
+ <script type="text/javascript">
+ (function() {
+ window.open('../../database/');
+ })();
+ </script>
+ <!--###END_HEAD###-->
+</head>
+<body>
+<!--###BEGIN_CONTENT###-->
+<h1>Manage Marmotta database via web-interface</h1>
+<a href="../../database/" target="_blank">Open database administration page in new window.</a>
+<!--###END_CONTENT###-->
+</body>
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d26c9a5c/platform/marmotta-backend-kiwi/src/main/resources/web/admin/js/widgets/database.js
----------------------------------------------------------------------
diff --git a/platform/marmotta-backend-kiwi/src/main/resources/web/admin/js/widgets/database.js b/platform/marmotta-backend-kiwi/src/main/resources/web/admin/js/widgets/database.js
new file mode 100644
index 0000000..42efb8e
--- /dev/null
+++ b/platform/marmotta-backend-kiwi/src/main/resources/web/admin/js/widgets/database.js
@@ -0,0 +1,303 @@
+/*
+ * 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.
+ */
+(function( $ ){
+ $.fn.lmf_database = function(options) {
+ var settings = {
+ host: 'http://localhost:8080/LMF/',
+ anker_name: 'database',
+ title: 'Database Configuration',
+ loading_img: '../public/img/loader/ajax-loader_small.gif',
+ toplink:true
+ }
+
+ //jquery elements
+ var table;
+
+ //basically there are 2 functions
+ //1. getValues from server and write it to inputFields
+ //2. storeValues after testing Configuration
+ var functions = {
+ input_fields:undefined,
+ getValues : function(callback) {
+
+ var writeValues = function(databases, values) {
+ table.html("");
+ this.input_fields={};
+
+ //DB Type
+ var tr1 = $("<tr/>");
+ var td11 = $("<td/>").css({"font-weight":"bold"}).text("Database: ");
+ var td12 = $("<td/>");
+ this.input_fields.db_select = $("<select/>").css({'width':'200px'});
+ for (value in databases) {
+ this.input_fields.db_select.append("<option>" + databases[value] + "</option>");
+ }
+ this.input_fields.db_select.val(values["database.type"]);
+ td12.append(this.input_fields.db_select);
+ this.input_fields.l_div = $("<div style='float:right;margin-top: -55px;'></div>");
+ table.parent().append(this.input_fields.l_div);
+ td11.appendTo(tr1);
+ td12.appendTo(tr1);
+ tr1.appendTo(table);
+
+ //DBHost
+ var tr2 = $("<tr/>");
+ var td21 = $("<td/>").css({"font-weight":"bold"}).text("Host: ");
+ var td22 = $("<td/>");
+ this.input_fields.db_host = $("<input type='text' style='width:100%'/>");
+ this.input_fields.db_host.val(values["database.url"]);
+ td22.append(this.input_fields.db_host);
+ td21.appendTo(tr2);
+ td22.appendTo(tr2);
+ tr2.appendTo(table);
+
+ //DBUser
+ var tr3 = $("<tr/>");
+ var td31 = $("<td/>").css({"font-weight":"bold"}).text("User: ");
+ var td32 = $("<td/>");
+ this.input_fields.db_user = $("<input type='text' style='width:100%'/>");
+ this.input_fields.db_user.val(values["database.user"]);
+ td32.append(this.input_fields.db_user);
+ td31.appendTo(tr3);
+ td32.appendTo(tr3);
+ tr3.appendTo(table);
+
+ //DB password
+ var tr4 = $("<tr/>");
+ var td41 = $("<td/>").css({"font-weight":"bold"}).text("Password: ");
+ var td42 = $("<td/>");
+ this.input_fields.db_pass = $("<input type='password' style='width:100%'/>");
+ this.input_fields.db_pass.val(values["database.password"]);
+ td42.append(this.input_fields.db_pass);
+ td41.appendTo(tr4);
+ td42.appendTo(tr4);
+ tr4.appendTo(table);
+
+ this.input_fields.db_select.change(function() {
+ getUrlValue();
+ });
+
+ if (callback) callback();
+ };
+
+ var getDatabases = function() {
+ //get prefixes
+ var url = settings.host+"config/list?prefix=database";
+ var that = this;
+ $.getJSON(url,function(data) {
+ var values = [];
+ var databases = new Array();
+ for(var property in data) {
+ property = property.substring(property.indexOf('.')+1);
+ property = property.substring(0,property.indexOf('.'));
+ if(property!="") {
+ if($.inArray(property,databases)==-1) {
+ databases.push(property);
+ }
+ }
+ }
+ getDBType(databases,new Array());
+ });
+ };
+
+ var getDBType = function(databases,values) {
+ var cid = "database.type";
+ var url = settings.host+"config/data/"+cid;
+ $.getJSON(url,function(data) {
+ values[cid] = data[cid];
+ getDBHost(databases,values);
+ });
+ };
+
+ var getDBHost = function(databases,values) {
+ var cid = "database.url";
+ var url = settings.host+"config/data/"+cid;
+ $.getJSON(url,function(data) {
+ values[cid] = data[cid];
+ getDBUser(databases,values);
+ });
+ };
+
+ var getDBUser = function(databases,values) {
+ var cid = "database.user";
+ var url = settings.host+"config/data/"+cid;
+ $.getJSON(url,function(data) {
+ values[cid] = data[cid];
+ getDBPass(databases,values);
+ });
+ };
+
+ var getDBPass = function(databases,values) {
+ var cid = "database.password";
+ var url = settings.host+"config/data/"+cid;
+ $.getJSON(url,function(data) {
+ values[cid] = data[cid];
+ writeValues(databases,values);
+ });
+
+ };
+ getDatabases();
+
+ //helper
+ function getUrlValue() {
+ var that = this;
+ $.getJSON(settings.host+"config/data/"+"database."+this.input_fields.db_select.val()+".url",function(data){
+ that.input_fields.db_host.val(data["database."+that.input_fields.db_select.val()+".url"]);
+ })
+ }
+ },
+
+ ping:function() {
+ var that = this;
+ var dburl = input_fields.db_host.val();
+ if (input_fields.db_host.val().indexOf(";") > 0) {
+ dburl = input_fields.db_host.val().substring(0, input_fields.db_host.val().indexOf(";"));
+ }
+ var url = settings.host + "storage-kiwi/ping?type=" + input_fields.db_select.val() + "&url=" + dburl + "&user=" + input_fields.db_user.val() + "&pwd=" + input_fields.db_pass.val();
+ $.ajax({
+ type:"POST",
+ url: url,
+ success: function() {
+ if(confirm("Configuration Test successfully! Save values?")){
+ that.saveValues();
+ }
+ },
+ error: function(jqXHR, statusText, errorThrown) {
+ alert(errorThrown + "(" + jqXHR.status + "):\n"+jqXHR.responseText)
+ }
+ });
+ },
+
+ saveValues: function(callback) {
+
+ var saveDatabase = function() {
+ $.ajax({
+ type:"POST",
+ contentType: "application/json",
+ url: settings.host + "config/data/database.type",
+ data: '["' + input_fields.db_select.val() + '"]',
+ success: function() {
+ saveUrl();
+ },
+ error: function(jqXHR, statusText, errorThrown) {
+ that.input_fields.l_div.html("");
+ alert("Error: " + errorThrown + "(" + jqXHR.status + ")" + jqXHR.responseText);
+ }
+ });
+ }
+
+ function saveUrl() {
+ $.ajax({
+ type:"POST",
+ contentType: "application/json",
+ url: settings.host + "config/data/database.url",
+ data: '["' + input_fields.db_host.val() + '"]',
+ success: function() {
+ saveUser();
+ },
+ error: function(jqXHR, statusText, errorThrown) {
+ that.input_fields.l_div.html("");
+ alert("Error: " + errorThrown + "(" + jqXHR.status + ")" + jqXHR.responseText);
+ }
+ });
+ }
+
+ function saveUser() {
+ $.ajax({
+ type:"POST",
+ contentType: "application/json",
+ url: settings.host + "config/data/database.user",
+ data: '["' + input_fields.db_user.val() + '"]',
+ success: function() {
+ savePwd();
+ },
+ error: function(jqXHR, statusText, errorThrown) {
+ that.input_fields.l_div.html("");
+ alert("Error: " + errorThrown + "(" + jqXHR.status + ")" + jqXHR.responseText);
+ }
+ });
+ }
+
+ function savePwd() {
+ $.ajax({
+ type:"POST",
+ contentType: "application/json",
+ url: settings.host + "config/data/database.password",
+ data: '["' + input_fields.db_pass.val() + '"]',
+ success: function() {
+ reinit();
+ },
+ error: function(jqXHR, statusText, errorThrown) {
+ that.input_fields.l_div.html("");
+ alert("Error: " + errorThrown + "(" + jqXHR.status + ")" + jqXHR.responseText);
+ }
+ });
+ }
+
+ function reinit() {
+ var that = this;
+ input_fields.l_div.html("<span>Reinitialize Database </span><img src='" + settings.loading_img + "'/>");
+ $.ajax({
+ type:"POST",
+ url: settings.host + "system/database/reinit",
+ success: function() {
+ that.input_fields.l_div.html("");
+ alert("Successfully reloaded!")
+ },
+ error: function(jqXHR, statusText, errorThrown) {
+ that.input_fields.l_div.html("");
+ alert("Error: " + errorThrown + "(" + jqXHR.status + ")" + jqXHR.responseText);
+ }
+ });
+ }
+ saveDatabase();
+ }
+ }
+
+ /**
+ * main method
+ */
+ return this.each(function() {
+ // merge options
+ if ( options ) {
+ $.extend( settings, options );
+ }
+ //build skeleton
+
+ //get Values
+ functions.getValues();
+ var top="";
+ if(settings.toplink)top='<a href="#" target="_top" style="position:absolute;right:5px;font-size:12px;top:7px;text-decoration:none;">top</a>';
+ //build basic view elements
+ var title = $("<h2 style='position:relative;margin-bottom:10px'><a style='text-decoration:none' name='"+settings.anker_name+"'>"+settings.title+"</a><span style='margin-left:10px;display:none;' class='tiny_text,lmf_configurator_loader'><img src='"+settings.loading_img+"' alt='loading...'></span>"+top+"</h2>");
+ table = $("<table style='margin:0px auto;background-color:#eeeeee;padding:20px;border:1px solid gray;-webkit-border-radius: 3px;border-radius: 3px;'></table>");
+ var buttons = $("<div style='width:100%;text-align:center;padding-top:10px;margin-bottom:30px;'></div>");
+ var b1 = $("<button>Reload</button>").click(function(){if(confirm("Discard all changes?"))functions.getValues()});
+ var b3 = $("<button style='margin-left:10px;'>Test Configuration</button>").click(function(){functions.ping()});
+ buttons.append(b1);
+ buttons.append(b3);
+
+ //append elements
+ $(this).html("");
+ $(this).append(title);
+ $(this).append(table);
+ $(this).append(buttons);
+ });
+ };
+})( jQuery );
+
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d26c9a5c/platform/marmotta-backend-native/src/main/resources/kiwi-module.properties
----------------------------------------------------------------------
diff --git a/platform/marmotta-backend-native/src/main/resources/kiwi-module.properties b/platform/marmotta-backend-native/src/main/resources/kiwi-module.properties
new file mode 100644
index 0000000..5dc4a7b
--- /dev/null
+++ b/platform/marmotta-backend-native/src/main/resources/kiwi-module.properties
@@ -0,0 +1,41 @@
+#
+# 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.
+#
+
+name=Storage Backend: Native
+
+container=Generic
+container.weight = 10
+
+subtitle = Configure Native Backend
+weight = 10
+
+icon_small = /admin/img/config_small.png
+
+#do not change!!!
+baseurl=/storage-native
+
+adminpage.0.title=About
+adminpage.0.link=/admin/about.html
+
+adminpage.1.title=Configuration
+adminpage.1.link=/admin/configuration.html
+
+adminpage.2.title=Database
+adminpage.2.link=/admin/database.html
+
+webservices=
+
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d26c9a5c/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/system/SystemWebService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/system/SystemWebService.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/system/SystemWebService.java
index 7c0dd35..08c669e 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/system/SystemWebService.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/system/SystemWebService.java
@@ -17,7 +17,6 @@
*/
package org.apache.marmotta.platform.core.webservices.system;
-import org.apache.marmotta.platform.core.api.config.ConfigurationService;
import org.apache.marmotta.platform.core.api.triplestore.SesameService;
import org.apache.marmotta.platform.core.jaxrs.ErrorResponse;
import org.slf4j.Logger;
@@ -26,11 +25,7 @@ import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
-import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
/**
* Perform various system actions like restarting database access or rebuilding indexes.
@@ -42,9 +37,6 @@ public class SystemWebService {
@Inject
private Logger log;
- @Inject
- private ConfigurationService configurationService;
-
@Inject
private SesameService sesameService;
@@ -70,60 +62,4 @@ public class SystemWebService {
return ErrorResponse.errorResponse(Response.Status.INTERNAL_SERVER_ERROR, ex);
}
}
-
- /**
- * Manually trigger the garbage collector.
- *
- * @return ok if successful, 500 if not
- * @HTTP 200 if garbage collection completed successfully
- * @HTTP 500 if there was an error while running garbage collection (see log)
- */
- @POST
- @Path("/database/gc")
- public Response garbageCollector() {
- log.info("Running triple store garbage collection after admin user request ...");
- try {
- sesameService.garbageCollect();
-
- return Response.ok().entity("garbage collection completed successfully").build();
- } catch(Exception ex) {
- log.error("Error while running garbage collection ...",ex);
- return ErrorResponse.errorResponse(Response.Status.INTERNAL_SERVER_ERROR, ex);
- }
- }
-
-
- @POST
- @Path("/database/ping")
- public Response pingDatabase(@QueryParam("type")String type,@QueryParam("url")String url,@QueryParam("user")String user,@QueryParam("pwd")String pwd) {
- if(type==null||url==null||user==null||pwd==null) {
- return Response.status(400).entity("one or more values are not defined").build();
- }
-
- //get driver
- String db_driver = configurationService.getStringConfiguration("database."+type+".driver");
- if(db_driver==null) {
- return ErrorResponse.errorResponse(Response.Status.INTERNAL_SERVER_ERROR,"driver for "+type+" not defined");
- }
-
- //try if type matches url
- if(!url.startsWith("jdbc:"+type)) {
- return ErrorResponse.errorResponse(Response.Status.INTERNAL_SERVER_ERROR,"database and url do not match properly");
- }
-
- //try to connect
- try {
- Class.forName(db_driver);
- Connection conn = DriverManager.getConnection(url,user,pwd);
- conn.close();
- return Response.ok().build();
- } catch (ClassNotFoundException e) {
- return ErrorResponse.errorResponse(Response.Status.INTERNAL_SERVER_ERROR,"Can't load driver ",e);
- } catch (SQLException e) {
- return ErrorResponse.errorResponse(Response.Status.INTERNAL_SERVER_ERROR,"Database access failed ",e);
- }
- }
-
-
-
}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d26c9a5c/platform/marmotta-core/src/main/resources/kiwi-module.properties
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/resources/kiwi-module.properties b/platform/marmotta-core/src/main/resources/kiwi-module.properties
index 37692bb..cace6ef 100644
--- a/platform/marmotta-core/src/main/resources/kiwi-module.properties
+++ b/platform/marmotta-core/src/main/resources/kiwi-module.properties
@@ -56,9 +56,6 @@ adminpage.7.link=/admin/prefixes.html
adminpage.8.title=System
adminpage.8.link=/admin/system.html
-adminpage.9.title=Database
-adminpage.9.link=/admin/database.html
-
webservices=org.apache.marmotta.platform.core.webservices.config.ConfigurationWebService,\
org.apache.marmotta.platform.core.webservices.config.DependenciesWebService,\
org.apache.marmotta.platform.core.webservices.system.SystemWebService,\
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d26c9a5c/platform/marmotta-core/src/main/resources/web/admin/database.html
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/resources/web/admin/database.html b/platform/marmotta-core/src/main/resources/web/admin/database.html
deleted file mode 100644
index 87b6835..0000000
--- a/platform/marmotta-core/src/main/resources/web/admin/database.html
+++ /dev/null
@@ -1,37 +0,0 @@
-<!--
-
- 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.
-
--->
-<html>
-<head>
- <!--###BEGIN_HEAD###-->
- <title>Core Module</title>
- <script type="text/javascript">
- (function() {
- window.open('../../database/');
- })();
- </script>
- <!--###END_HEAD###-->
-</head>
-<body>
-<!--###BEGIN_CONTENT###-->
-<h1>Manage Marmotta database via web-interface</h1>
-<a href="../../database/" target="_blank">Open database administration page in new window.</a>
-<!--###END_CONTENT###-->
-</body>
-</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d26c9a5c/platform/marmotta-core/src/main/resources/web/admin/js/widgets/database.js
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/resources/web/admin/js/widgets/database.js b/platform/marmotta-core/src/main/resources/web/admin/js/widgets/database.js
deleted file mode 100644
index 43a1391..0000000
--- a/platform/marmotta-core/src/main/resources/web/admin/js/widgets/database.js
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * 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.
- */
-(function( $ ){
- $.fn.lmf_database = function(options) {
- var settings = {
- host: 'http://localhost:8080/LMF/',
- anker_name: 'database',
- title: 'Database Configuration',
- loading_img: '../public/img/loader/ajax-loader_small.gif',
- toplink:true
- }
-
- //jquery elements
- var table;
-
- //basically there are 2 functions
- //1. getValues from server and write it to inputFields
- //2. storeValues after testing Configuration
- var functions = {
- input_fields:undefined,
- getValues : function(callback) {
-
- var writeValues = function(databases, values) {
- table.html("");
- this.input_fields={};
-
- //DB Type
- var tr1 = $("<tr/>");
- var td11 = $("<td/>").css({"font-weight":"bold"}).text("Database: ");
- var td12 = $("<td/>");
- this.input_fields.db_select = $("<select/>").css({'width':'200px'});
- for (value in databases) {
- this.input_fields.db_select.append("<option>" + databases[value] + "</option>");
- }
- this.input_fields.db_select.val(values["database.type"]);
- td12.append(this.input_fields.db_select);
- this.input_fields.l_div = $("<div style='float:right;margin-top: -55px;'></div>");
- table.parent().append(this.input_fields.l_div);
- td11.appendTo(tr1);
- td12.appendTo(tr1);
- tr1.appendTo(table);
-
- //DBHost
- var tr2 = $("<tr/>");
- var td21 = $("<td/>").css({"font-weight":"bold"}).text("Host: ");
- var td22 = $("<td/>");
- this.input_fields.db_host = $("<input type='text' style='width:100%'/>");
- this.input_fields.db_host.val(values["database.url"]);
- td22.append(this.input_fields.db_host);
- td21.appendTo(tr2);
- td22.appendTo(tr2);
- tr2.appendTo(table);
-
- //DBUser
- var tr3 = $("<tr/>");
- var td31 = $("<td/>").css({"font-weight":"bold"}).text("User: ");
- var td32 = $("<td/>");
- this.input_fields.db_user = $("<input type='text' style='width:100%'/>");
- this.input_fields.db_user.val(values["database.user"]);
- td32.append(this.input_fields.db_user);
- td31.appendTo(tr3);
- td32.appendTo(tr3);
- tr3.appendTo(table);
-
- //DB password
- var tr4 = $("<tr/>");
- var td41 = $("<td/>").css({"font-weight":"bold"}).text("Password: ");
- var td42 = $("<td/>");
- this.input_fields.db_pass = $("<input type='password' style='width:100%'/>");
- this.input_fields.db_pass.val(values["database.password"]);
- td42.append(this.input_fields.db_pass);
- td41.appendTo(tr4);
- td42.appendTo(tr4);
- tr4.appendTo(table);
-
- this.input_fields.db_select.change(function() {
- getUrlValue();
- });
-
- if (callback) callback();
- };
-
- var getDatabases = function() {
- //get prefixes
- var url = settings.host+"config/list?prefix=database";
- var that = this;
- $.getJSON(url,function(data) {
- var values = [];
- var databases = new Array();
- for(var property in data) {
- property = property.substring(property.indexOf('.')+1);
- property = property.substring(0,property.indexOf('.'));
- if(property!="") {
- if($.inArray(property,databases)==-1) {
- databases.push(property);
- }
- }
- }
- getDBType(databases,new Array());
- });
- };
-
- var getDBType = function(databases,values) {
- var cid = "database.type";
- var url = settings.host+"config/data/"+cid;
- $.getJSON(url,function(data) {
- values[cid] = data[cid];
- getDBHost(databases,values);
- });
- };
-
- var getDBHost = function(databases,values) {
- var cid = "database.url";
- var url = settings.host+"config/data/"+cid;
- $.getJSON(url,function(data) {
- values[cid] = data[cid];
- getDBUser(databases,values);
- });
- };
-
- var getDBUser = function(databases,values) {
- var cid = "database.user";
- var url = settings.host+"config/data/"+cid;
- $.getJSON(url,function(data) {
- values[cid] = data[cid];
- getDBPass(databases,values);
- });
- };
-
- var getDBPass = function(databases,values) {
- var cid = "database.password";
- var url = settings.host+"config/data/"+cid;
- $.getJSON(url,function(data) {
- values[cid] = data[cid];
- writeValues(databases,values);
- });
-
- };
- getDatabases();
-
- //helper
- function getUrlValue() {
- var that = this;
- $.getJSON(settings.host+"config/data/"+"database."+this.input_fields.db_select.val()+".url",function(data){
- that.input_fields.db_host.val(data["database."+that.input_fields.db_select.val()+".url"]);
- })
- }
- },
-
- ping:function() {
- var that = this;
- var dburl = input_fields.db_host.val();
- if (input_fields.db_host.val().indexOf(";") > 0) {
- dburl = input_fields.db_host.val().substring(0, input_fields.db_host.val().indexOf(";"));
- }
- var url = settings.host + "system/database/ping?type=" + input_fields.db_select.val() + "&url=" + dburl + "&user=" + input_fields.db_user.val() + "&pwd=" + input_fields.db_pass.val();
- $.ajax({
- type:"POST",
- url: url,
- success: function() {
- if(confirm("Configuration Test successfully! Save values?")){
- that.saveValues();
- }
- },
- error: function(jqXHR, statusText, errorThrown) {
- alert(errorThrown + "(" + jqXHR.status + "):\n"+jqXHR.responseText)
- }
- });
- },
-
- saveValues: function(callback) {
-
- var saveDatabase = function() {
- $.ajax({
- type:"POST",
- contentType: "application/json",
- url: settings.host + "config/data/database.type",
- data: '["' + input_fields.db_select.val() + '"]',
- success: function() {
- saveUrl();
- },
- error: function(jqXHR, statusText, errorThrown) {
- that.input_fields.l_div.html("");
- alert("Error: " + errorThrown + "(" + jqXHR.status + ")" + jqXHR.responseText);
- }
- });
- }
-
- function saveUrl() {
- $.ajax({
- type:"POST",
- contentType: "application/json",
- url: settings.host + "config/data/database.url",
- data: '["' + input_fields.db_host.val() + '"]',
- success: function() {
- saveUser();
- },
- error: function(jqXHR, statusText, errorThrown) {
- that.input_fields.l_div.html("");
- alert("Error: " + errorThrown + "(" + jqXHR.status + ")" + jqXHR.responseText);
- }
- });
- }
-
- function saveUser() {
- $.ajax({
- type:"POST",
- contentType: "application/json",
- url: settings.host + "config/data/database.user",
- data: '["' + input_fields.db_user.val() + '"]',
- success: function() {
- savePwd();
- },
- error: function(jqXHR, statusText, errorThrown) {
- that.input_fields.l_div.html("");
- alert("Error: " + errorThrown + "(" + jqXHR.status + ")" + jqXHR.responseText);
- }
- });
- }
-
- function savePwd() {
- $.ajax({
- type:"POST",
- contentType: "application/json",
- url: settings.host + "config/data/database.password",
- data: '["' + input_fields.db_pass.val() + '"]',
- success: function() {
- reinit();
- },
- error: function(jqXHR, statusText, errorThrown) {
- that.input_fields.l_div.html("");
- alert("Error: " + errorThrown + "(" + jqXHR.status + ")" + jqXHR.responseText);
- }
- });
- }
-
- function reinit() {
- var that = this;
- input_fields.l_div.html("<span>Reinitialize Database </span><img src='" + settings.loading_img + "'/>");
- $.ajax({
- type:"POST",
- url: settings.host + "system/database/reinit",
- success: function() {
- that.input_fields.l_div.html("");
- alert("Successfully reloaded!")
- },
- error: function(jqXHR, statusText, errorThrown) {
- that.input_fields.l_div.html("");
- alert("Error: " + errorThrown + "(" + jqXHR.status + ")" + jqXHR.responseText);
- }
- });
- }
- saveDatabase();
- }
- }
-
- /**
- * main method
- */
- return this.each(function() {
- // merge options
- if ( options ) {
- $.extend( settings, options );
- }
- //build skeleton
-
- //get Values
- functions.getValues();
- var top="";
- if(settings.toplink)top='<a href="#" target="_top" style="position:absolute;right:5px;font-size:12px;top:7px;text-decoration:none;">top</a>';
- //build basic view elements
- var title = $("<h2 style='position:relative;margin-bottom:10px'><a style='text-decoration:none' name='"+settings.anker_name+"'>"+settings.title+"</a><span style='margin-left:10px;display:none;' class='tiny_text,lmf_configurator_loader'><img src='"+settings.loading_img+"' alt='loading...'></span>"+top+"</h2>");
- table = $("<table style='margin:0px auto;background-color:#eeeeee;padding:20px;border:1px solid gray;-webkit-border-radius: 3px;border-radius: 3px;'></table>");
- var buttons = $("<div style='width:100%;text-align:center;padding-top:10px;margin-bottom:30px;'></div>");
- var b1 = $("<button>Reload</button>").click(function(){if(confirm("Discard all changes?"))functions.getValues()});
- var b3 = $("<button style='margin-left:10px;'>Test Configuration</button>").click(function(){functions.ping()});
- buttons.append(b1);
- buttons.append(b3);
-
- //append elements
- $(this).html("");
- $(this).append(title);
- $(this).append(table);
- $(this).append(buttons);
- });
- };
-})( jQuery );
-