cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r495334 - in /cocoon/trunk/blocks/cocoon-databases: cocoon-databases-hsqldb-server/src/main/java/org/apache/cocoon/components/hsqldb/ cocoon-databases-sample/src/main/resources/META-INF/cocoon/spring/
Date Thu, 11 Jan 2007 19:03:44 GMT
Author: cziegeler
Date: Thu Jan 11 11:03:43 2007
New Revision: 495334

URL: http://svn.apache.org/viewvc?view=rev&rev=495334
Log:
Fix problems with database paths
Use configuration override mechanism to start samples database

Added:
    cocoon/trunk/blocks/cocoon-databases/cocoon-databases-sample/src/main/resources/META-INF/cocoon/spring/
    cocoon/trunk/blocks/cocoon-databases/cocoon-databases-sample/src/main/resources/META-INF/cocoon/spring/cocoon-databases-sample.properties
  (with props)
Modified:
    cocoon/trunk/blocks/cocoon-databases/cocoon-databases-hsqldb-server/src/main/java/org/apache/cocoon/components/hsqldb/ServerImpl.java

Modified: cocoon/trunk/blocks/cocoon-databases/cocoon-databases-hsqldb-server/src/main/java/org/apache/cocoon/components/hsqldb/ServerImpl.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-databases/cocoon-databases-hsqldb-server/src/main/java/org/apache/cocoon/components/hsqldb/ServerImpl.java?view=diff&rev=495334&r1=495333&r2=495334
==============================================================================
--- cocoon/trunk/blocks/cocoon-databases/cocoon-databases-hsqldb-server/src/main/java/org/apache/cocoon/components/hsqldb/ServerImpl.java
(original)
+++ cocoon/trunk/blocks/cocoon-databases/cocoon-databases-hsqldb-server/src/main/java/org/apache/cocoon/components/hsqldb/ServerImpl.java
Thu Jan 11 11:03:43 2007
@@ -18,6 +18,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.net.URL;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Properties;
@@ -142,13 +143,27 @@
                 this.getLogger().debug("Configuring database " + name + " with path " + dbCfgPath);
             }
             String dbPath = dbCfgPath;
-            // Test if we are running inside a WAR file
+            // is the context protocol used? 
             if (dbPath.startsWith(ServerImpl.CONTEXT_PROTOCOL)) {
+                // Test if we are running inside a WAR file
                 dbPath = this.servletContext.getRealPath(dbPath.substring(ServerImpl.CONTEXT_PROTOCOL.length()));
-            }
-            if (dbPath == null) {
-                throw new IllegalArgumentException("The hsqldb cannot be used inside an unexpanded
WAR file. " +
-                                             "Real path for <" + dbCfgPath + "> is
null.");
+                if (dbPath == null) {
+                    throw new IllegalArgumentException("The hsqldb cannot be used inside
an unexpanded WAR file. " +
+                                                 "Real path for <" + dbCfgPath + ">
is null.");
+                }
+            } else {
+                // is this a file url
+                if ( dbPath.startsWith("file:") ) {
+                    dbPath = dbPath.substring(5);
+                }
+                // we test if the path points to a directory in the file system
+                final File directory = new File(dbPath);
+                if ( !directory.exists() ) {
+                    throw new IllegalArgumentException("Path for hsqldb database does not
exist: " + dbPath);
+                }
+                if ( !directory.isDirectory() ) {
+                    throw new IllegalArgumentException("Path for hsqldb database does not
point to a directory: " + dbPath);
+                }
             }
 
             try {

Added: cocoon/trunk/blocks/cocoon-databases/cocoon-databases-sample/src/main/resources/META-INF/cocoon/spring/cocoon-databases-sample.properties
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-databases/cocoon-databases-sample/src/main/resources/META-INF/cocoon/spring/cocoon-databases-sample.properties?view=auto&rev=495334
==============================================================================
--- cocoon/trunk/blocks/cocoon-databases/cocoon-databases-sample/src/main/resources/META-INF/cocoon/spring/cocoon-databases-sample.properties
(added)
+++ cocoon/trunk/blocks/cocoon-databases/cocoon-databases-sample/src/main/resources/META-INF/cocoon/spring/cocoon-databases-sample.properties
Thu Jan 11 11:03:43 2007
@@ -0,0 +1,19 @@
+#  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.
+#
+# @version $Id$
+#
+# Let's override the default path for the hsqldb {bean name}/{property name}={value}
+org.apache.cocoon.components.hsqldb.Server/databases=cocoondb\=${org.apache.cocoon.blocks.cocoon-databases-sample.resources}/hsqldb
\ No newline at end of file

Propchange: cocoon/trunk/blocks/cocoon-databases/cocoon-databases-sample/src/main/resources/META-INF/cocoon/spring/cocoon-databases-sample.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-databases/cocoon-databases-sample/src/main/resources/META-INF/cocoon/spring/cocoon-databases-sample.properties
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message