dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #07027
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1969: Added login notification when running in-memory database
Merge authors:
Lars <larshelg@larshelg-laptop>
------------------------------------------------------------
revno: 1969 [merge]
committer: Lars <larshelg@larshelg-laptop>
branch nick: trunk
timestamp: Thu 2010-08-26 07:33:47 +0200
message:
Added login notification when running in-memory database
added:
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/ContextInterceptor.java
modified:
dhis-2/dhis-support/dhis-support-external/src/main/java/org/hisp/dhis/external/location/DefaultLocationManager.java
dhis-2/dhis-support/dhis-support-hibernate/pom.xml
dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/database/DatabaseInfoProvider.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/database/HibernateDatabaseInfoProvider.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java
dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml
dhis-2/dhis-web/dhis-web-portal/src/main/resources/org/hisp/dhis/wp/i18n_module.properties
dhis-2/dhis-web/dhis-web-portal/src/main/webapp/dhis-web-portal/redirect.vm
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-support/dhis-support-external/src/main/java/org/hisp/dhis/external/location/DefaultLocationManager.java'
--- dhis-2/dhis-support/dhis-support-external/src/main/java/org/hisp/dhis/external/location/DefaultLocationManager.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-support/dhis-support-external/src/main/java/org/hisp/dhis/external/location/DefaultLocationManager.java 2010-08-25 19:53:05 +0000
@@ -50,7 +50,7 @@
{
private static final Log log = LogFactory.getLog( DefaultLocationManager.class );
- private static final String LINUX_DEFAULT_DHIS2_HOME = "/opt/dhis2";
+ private static final String DEFAULT_DHIS2_HOME = "/opt/dhis2";
private String externalDir = null;
@@ -108,16 +108,13 @@
else
{
log.info( "Environment variable " + environmentVariable + " not set" );
- // if Linux try fallback to /opt/dhis2
- // if ( LINUX_OS_NAME.equals( System.getProperty("os.name") ) )
- if ( true )
+
+ path = DEFAULT_DHIS2_HOME;
+
+ if ( directoryIsValid( new File( path ) ) )
{
- path = LINUX_DEFAULT_DHIS2_HOME;
- if ( directoryIsValid( new File( path ) ) )
- {
- externalDir = path;
- log.info( "externalDir set to " + LINUX_DEFAULT_DHIS2_HOME );
- }
+ externalDir = path;
+ log.info( "Home directory set to " + DEFAULT_DHIS2_HOME );
}
}
}
=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/pom.xml'
--- dhis-2/dhis-support/dhis-support-hibernate/pom.xml 2010-08-20 09:13:09 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/pom.xml 2010-08-25 19:53:05 +0000
@@ -28,7 +28,6 @@
<!-- Hibernate -->
-
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/META-INF/dhis/beans.xml 2010-05-17 22:14:26 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/META-INF/dhis/beans.xml 2010-08-25 19:53:05 +0000
@@ -19,8 +19,7 @@
<!-- Configuration -->
- <bean id="sessionFactory"
- class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
+ <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="hibernateProperties" ref="hibernateProperties"/>
<property name="mappingJarLocations" ref="hibernateMappingJarLocations"/>
@@ -38,23 +37,19 @@
<property name="dataSource" ref="dataSource"/>
</bean>
- <bean id="driverClassName"
- class="org.hisp.dhis.hibernate.ConnectionPropertyFactoryBean">
+ <bean id="driverClassName" class="org.hisp.dhis.hibernate.ConnectionPropertyFactoryBean">
<property name="hibernateProperty" value="hibernate.connection.driver_class"/>
</bean>
- <bean id="url"
- class="org.hisp.dhis.hibernate.ConnectionPropertyFactoryBean">
+ <bean id="url" class="org.hisp.dhis.hibernate.ConnectionPropertyFactoryBean">
<property name="hibernateProperty" value="hibernate.connection.url"/>
</bean>
- <bean id="username"
- class="org.hisp.dhis.hibernate.ConnectionPropertyFactoryBean">
+ <bean id="username" class="org.hisp.dhis.hibernate.ConnectionPropertyFactoryBean">
<property name="hibernateProperty" value="hibernate.connection.username"/>
</bean>
- <bean id="password"
- class="org.hisp.dhis.hibernate.ConnectionPropertyFactoryBean">
+ <bean id="password" class="org.hisp.dhis.hibernate.ConnectionPropertyFactoryBean">
<property name="hibernateProperty" value="hibernate.connection.password"/>
</bean>
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/database/DatabaseInfoProvider.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/database/DatabaseInfoProvider.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/database/DatabaseInfoProvider.java 2010-08-25 19:53:05 +0000
@@ -36,4 +36,6 @@
String ID = DatabaseInfoProvider.class.getName();
DatabaseInfo getDatabaseInfo();
+
+ boolean isInMemory();
}
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/database/HibernateDatabaseInfoProvider.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/database/HibernateDatabaseInfoProvider.java 2010-05-18 13:42:38 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/database/HibernateDatabaseInfoProvider.java 2010-08-25 19:53:05 +0000
@@ -106,4 +106,9 @@
{
return info;
}
+
+ public boolean isInMemory()
+ {
+ return info.getUrl() != null && info.getUrl().contains( ":mem:" );
+ }
}
=== added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/ContextInterceptor.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/ContextInterceptor.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/ContextInterceptor.java 2010-08-26 05:33:47 +0000
@@ -0,0 +1,69 @@
+package org.hisp.dhis.interceptor;
+
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.hisp.dhis.system.database.DatabaseInfoProvider;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.interceptor.Interceptor;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class ContextInterceptor
+ implements Interceptor
+{
+ private static final String KEY_IN_MEMORY_DATABASE = "inMemoryDatabase";
+
+ @Autowired
+ private DatabaseInfoProvider databaseInfoProvider;
+
+ @Override
+ public void destroy()
+ {
+ }
+
+ @Override
+ public void init()
+ {
+ }
+
+ @Override
+ public String intercept( ActionInvocation invocation )
+ throws Exception
+ {
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put( KEY_IN_MEMORY_DATABASE, databaseInfoProvider.isInMemory() );
+ invocation.getStack().push( map );
+ return invocation.invoke();
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java 2010-06-19 18:48:05 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java 2010-08-25 19:53:05 +0000
@@ -84,7 +84,7 @@
public String intercept( ActionInvocation invocation )
throws Exception
{
- Map<String, Object> map = new HashMap<String, Object>( 2 );
+ Map<String, Object> map = new HashMap<String, Object>();
map.put( KEY_APPLICATION_TITLE, systemSettingManager.getSystemSetting( KEY_APPLICATION_TITLE ) );
map.put( KEY_MAX_NUMBER_OF_ATTEMPTS, systemSettingManager.getSystemSetting( KEY_MAX_NUMBER_OF_ATTEMPTS, DEFAULT_MAX_NUMBER_OF_ATTEMPTS ) );
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2010-08-18 07:19:54 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2010-08-25 19:53:05 +0000
@@ -727,6 +727,9 @@
<property name="systemSettingManager" ref="org.hisp.dhis.options.SystemSettingManager" />
</bean>
+ <bean id="org.hisp.dhis.interceptor.ContextInterceptor"
+ class="org.hisp.dhis.interceptor.ContextInterceptor"/>
+
<bean id="org.hisp.dhis.useraccount.action.GetCurrentUserAction"
class="org.hisp.dhis.useraccount.action.GetCurrentUserAction" scope="prototype">
<property name="currentUserService">
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2010-08-17 07:26:22 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2010-08-25 19:53:05 +0000
@@ -47,6 +47,8 @@
class="org.hisp.dhis.interceptor.SystemSettingInterceptor" />
<interceptor name="styleInterceptor"
class="org.hisp.dhis.interceptor.StyleInterceptor" />
+ <interceptor name="contextInterceptor"
+ class="org.hisp.dhis.interceptor.ContextInterceptor" />
<interceptor name="portalParamsInterceptor"
class="org.hisp.dhis.webportal.interceptor.XWorkPortalParamsInterceptor" />
@@ -78,6 +80,7 @@
<interceptor-ref name="dataDictionaryModeInterceptor" />
<interceptor-ref name="systemSettingInterceptor" />
<interceptor-ref name="styleInterceptor" />
+ <interceptor-ref name="contextInterceptor"/>
<interceptor-ref name="portalParamsInterceptor" />
<interceptor-ref name="portalMenuInterceptor" />
<interceptor-ref name="portalModuleInterceptor" />
=== modified file 'dhis-2/dhis-web/dhis-web-portal/src/main/resources/org/hisp/dhis/wp/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-portal/src/main/resources/org/hisp/dhis/wp/i18n_module.properties 2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-web/dhis-web-portal/src/main/resources/org/hisp/dhis/wp/i18n_module.properties 2010-08-25 19:53:05 +0000
@@ -3,4 +3,6 @@
dhis2_issue_tracking = DHIS 2 Issue Tracking
welcome_to_dhis2 = Welcome to DHIS 2
get_help_here = Get help here
-loading = Loading
\ No newline at end of file
+loading = Loading
+proceed = Proceed
+in_memory_notification = The database is currently running in-memory. This is useful for testing purposes but might happen because your database configuration was not picked up. Please make sure this is intentional. Your data will be destroyed when the application shuts down.
=== modified file 'dhis-2/dhis-web/dhis-web-portal/src/main/webapp/dhis-web-portal/redirect.vm'
--- dhis-2/dhis-web/dhis-web-portal/src/main/webapp/dhis-web-portal/redirect.vm 2009-03-23 16:30:43 +0000
+++ dhis-2/dhis-web/dhis-web-portal/src/main/webapp/dhis-web-portal/redirect.vm 2010-08-25 19:53:05 +0000
@@ -1,10 +1,19 @@
<script type="text/javascript">
+function redirect()
+{
#if ( $startModule && $auth.hasAccess( $startModule, "index" ) )
- window.location.href = "../${startModule}/index.action";
+ window.location.href = "../${startModule}/index.action";jy
#else
window.location.href = "intro.action";
#end
+}
+
+#if ( !$inMemoryDatabase )
+redirect();
+#end
</script>
-<p>$i18n.getString( "loading" )...</p>
\ No newline at end of file
+<span id="info">$i18n.getString( "in_memory_notification" )</span>
+
+<p><input type="button" value="$i18n.getString( 'proceed' )" onclick="redirect()"></p>
\ No newline at end of file