dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24259
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11853: Pushed system info code to service layer. Exposing more system info through web api at /system/info.
------------------------------------------------------------
revno: 11853
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2013-09-01 23:38:52 +0200
message:
Pushed system info code to service layer. Exposing more system info through web api at /system/info.
added:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/system/
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/system/DefaultSystemService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/system/SystemService.java
renamed:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/SystemInfo.java => dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/system/SystemInfo.java
modified:
dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SystemController.java
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/about/about.vm
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/about/action/AboutAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/system/SystemInfo.java
--
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
=== added directory 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/system'
=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/system/DefaultSystemService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/system/DefaultSystemService.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/system/DefaultSystemService.java 2013-09-01 21:38:52 +0000
@@ -0,0 +1,161 @@
+package org.hisp.dhis.system;
+
+/*
+ * Copyright (c) 2004-2013, 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.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Properties;
+
+import org.apache.commons.io.IOUtils;
+import org.hisp.dhis.external.location.LocationManager;
+import org.hisp.dhis.external.location.LocationManagerException;
+import org.hisp.dhis.system.database.DatabaseInfoProvider;
+import org.hisp.dhis.system.util.SystemUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.ClassPathResource;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class DefaultSystemService
+ implements SystemService
+{
+ @Autowired
+ private LocationManager locationManager;
+
+ @Autowired
+ private DatabaseInfoProvider databaseInfoProvider;
+
+ // -------------------------------------------------------------------------
+ // SystemService implementation
+ // -------------------------------------------------------------------------
+
+ @Override
+ public SystemInfo getSystemInfo()
+ {
+ SystemInfo info = new SystemInfo();
+
+ // ---------------------------------------------------------------------
+ // Version
+ // ---------------------------------------------------------------------
+
+ ClassPathResource resource = new ClassPathResource( "build.properties" );
+
+ if ( resource.isReadable() )
+ {
+ InputStream in = null;
+
+ try
+ {
+ in = resource.getInputStream();
+
+ Properties properties = new Properties();
+
+ properties.load( in );
+
+ info.setVersion( properties.getProperty( "build.version" ) );
+ info.setRevision( properties.getProperty( "build.revision" ) );
+
+ String buildTime = properties.getProperty( "build.time" );
+
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" );
+
+ info.setBuildTime( dateFormat.parse( buildTime ) );
+ }
+ catch ( IOException ex )
+ {
+ // Do nothing
+ }
+ catch ( ParseException ex )
+ {
+ // Do nothing
+ }
+ finally
+ {
+ IOUtils.closeQuietly( in );
+ }
+ }
+
+ // ---------------------------------------------------------------------
+ // External directory
+ // ---------------------------------------------------------------------
+
+ info.setEnvironmentVariable( locationManager.getEnvironmentVariable() );
+
+ try
+ {
+ File directory = locationManager.getExternalDirectory();
+
+ info.setExternalDirectory( directory.getAbsolutePath() );
+ }
+ catch ( LocationManagerException ex )
+ {
+ info.setExternalDirectory( "Not set" );
+ }
+
+ // ---------------------------------------------------------------------
+ // Database
+ // ---------------------------------------------------------------------
+
+ info.setDatabaseInfo( databaseInfoProvider.getDatabaseInfo() );
+
+ // ---------------------------------------------------------------------
+ // System env variables and properties
+ // ---------------------------------------------------------------------
+
+ try
+ {
+ info.setJavaOpts( System.getenv( "JAVA_OPTS" ) );
+ }
+ catch ( SecurityException ex )
+ {
+ info.setJavaOpts( "Unknown" );
+ }
+
+ Properties props = System.getProperties();
+
+ info.setJavaIoTmpDir( props.getProperty( "java.io.tmpdir" ) );
+ info.setJavaVersion( props.getProperty( "java.version" ) );
+ info.setJavaVendor( props.getProperty( "java.vendor" ) );
+ info.setOsName( props.getProperty( "os.name" ) );
+ info.setOsArchitecture( props.getProperty( "os.arch" ) );
+ info.setOsVersion( props.getProperty( "os.version" ) );
+
+ info.setMemoryInfo( SystemUtils.getMemoryString() );
+ info.setCpuCores( SystemUtils.getCpuCores() );
+ info.setServerDate( new Date() );
+
+ return info;
+ }
+}
=== renamed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/SystemInfo.java' => 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/system/SystemInfo.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/SystemInfo.java 2013-08-23 16:00:30 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/system/SystemInfo.java 2013-09-01 21:38:52 +0000
@@ -1,4 +1,4 @@
-package org.hisp.dhis.api.webdomain;
+package org.hisp.dhis.system;
/*
* Copyright (c) 2004-2013, University of Oslo
@@ -28,17 +28,61 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.Date;
+
import org.hisp.dhis.common.DxfNamespaces;
+import org.hisp.dhis.system.database.DatabaseInfo;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+/**
+ * @author Lars Helge Overland
+ */
@JacksonXmlRootElement( localName = "systemInfo", namespace = DxfNamespaces.DXF_2_0 )
public class SystemInfo
{
private String contextPath;
+ private String userAgent;
+
+ private String version;
+
+ private String revision;
+
+ private Date buildTime;
+
+ private Date serverDate;
+
+ private String environmentVariable;
+
+ private String javaVersion;
+
+ private String javaVendor;
+
+ private String osName;
+
+ private String osArchitecture;
+
+ private String osVersion;
+
+ private String javaIoTmpDir;
+
+ private String externalDirectory;
+
+ private DatabaseInfo databaseInfo;
+
+ private String javaOpts;
+
+ private String memoryInfo;
+
+ private int cpuCores;
+
+ // -------------------------------------------------------------------------
+ // Getters and setters
+ // -------------------------------------------------------------------------
+
@JsonProperty
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public String getContextPath()
@@ -50,4 +94,186 @@
{
this.contextPath = contextPath;
}
+
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public String getUserAgent()
+ {
+ return userAgent;
+ }
+
+ public void setUserAgent( String userAgent )
+ {
+ this.userAgent = userAgent;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public String getVersion()
+ {
+ return version;
+ }
+
+ public void setVersion( String version )
+ {
+ this.version = version;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public String getRevision()
+ {
+ return revision;
+ }
+
+ public void setRevision( String revision )
+ {
+ this.revision = revision;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public Date getBuildTime()
+ {
+ return buildTime;
+ }
+
+ public void setBuildTime( Date buildTime )
+ {
+ this.buildTime = buildTime;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public Date getServerDate()
+ {
+ return serverDate;
+ }
+
+ public void setServerDate( Date serverDate )
+ {
+ this.serverDate = serverDate;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public String getEnvironmentVariable()
+ {
+ return environmentVariable;
+ }
+
+ public void setEnvironmentVariable( String environmentVariable )
+ {
+ this.environmentVariable = environmentVariable;
+ }
+
+ public String getJavaVersion()
+ {
+ return javaVersion;
+ }
+
+ public void setJavaVersion( String javaVersion )
+ {
+ this.javaVersion = javaVersion;
+ }
+
+ public String getJavaVendor()
+ {
+ return javaVendor;
+ }
+
+ public void setJavaVendor( String javaVendor )
+ {
+ this.javaVendor = javaVendor;
+ }
+
+ public String getOsName()
+ {
+ return osName;
+ }
+
+ public void setOsName( String osName )
+ {
+ this.osName = osName;
+ }
+
+ public String getOsArchitecture()
+ {
+ return osArchitecture;
+ }
+
+ public void setOsArchitecture( String osArchitecture )
+ {
+ this.osArchitecture = osArchitecture;
+ }
+
+ public String getOsVersion()
+ {
+ return osVersion;
+ }
+
+ public void setOsVersion( String osVersion )
+ {
+ this.osVersion = osVersion;
+ }
+
+ public String getJavaIoTmpDir()
+ {
+ return javaIoTmpDir;
+ }
+
+ public void setJavaIoTmpDir( String javaIoTmpDir )
+ {
+ this.javaIoTmpDir = javaIoTmpDir;
+ }
+
+ public String getExternalDirectory()
+ {
+ return externalDirectory;
+ }
+
+ public void setExternalDirectory( String externalDirectory )
+ {
+ this.externalDirectory = externalDirectory;
+ }
+
+ public DatabaseInfo getDatabaseInfo()
+ {
+ return databaseInfo;
+ }
+
+ public void setDatabaseInfo( DatabaseInfo databaseInfo )
+ {
+ this.databaseInfo = databaseInfo;
+ }
+
+ public String getJavaOpts()
+ {
+ return javaOpts;
+ }
+
+ public void setJavaOpts( String javaOpts )
+ {
+ this.javaOpts = javaOpts;
+ }
+
+ public String getMemoryInfo()
+ {
+ return memoryInfo;
+ }
+
+ public void setMemoryInfo( String memoryInfo )
+ {
+ this.memoryInfo = memoryInfo;
+ }
+
+ public int getCpuCores()
+ {
+ return cpuCores;
+ }
+
+ public void setCpuCores( int cpuCores )
+ {
+ this.cpuCores = cpuCores;
+ }
}
=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/system/SystemService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/system/SystemService.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/system/SystemService.java 2013-09-01 21:38:52 +0000
@@ -0,0 +1,37 @@
+package org.hisp.dhis.system;
+
+/*
+ * Copyright (c) 2004-2013, 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.
+ */
+
+/**
+ * @author Lars Helge Overland
+ */
+public interface SystemService
+{
+ SystemInfo getSystemInfo();
+}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2013-08-29 18:09:46 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2013-09-01 21:38:52 +0000
@@ -348,9 +348,6 @@
<property name="jdbcTemplate" ref="jdbcTemplate" />
</bean>
-
-
-
<!-- Service definitions -->
<bean id="org.hisp.dhis.dataelement.DataElementOperandService" class="org.hisp.dhis.dataelement.DefaultDataElementOperandService">
@@ -706,6 +703,8 @@
<bean id="org.hisp.dhis.appmanager.AppManagerService" class="org.hisp.dhis.appmanager.DefaultAppManagerService" />
+ <bean id="org.hisp.dhis.system.SystemService" class="org.hisp.dhis.system.DefaultSystemService" />
+
<!-- SMS Services -->
<bean id="org.hisp.dhis.sms.MessageQueue" class="org.hisp.dhis.sms.DatabaseSupportedInternalMemoryMessageQueue">
@@ -782,7 +781,6 @@
<property name="userService" ref="org.hisp.dhis.user.UserService" />
</bean>
-
<!-- I18nService -->
<bean id="org.hisp.dhis.i18n.I18nService" class="org.hisp.dhis.i18n.DefaultI18nService">
@@ -878,14 +876,6 @@
<property name="skipInTests" value="true" />
</bean>
- <!-- <bean id="org.hisp.dhis.user.UserDefaultPopulator"
- class="org.hisp.dhis.user.UserDefaultPopulator">
- <property name="userService" ref="org.hisp.dhis.user.UserService" />
- <property name="runlevel" value="5" />
- <property name="skipInTests" value="true" />
- </bean>
- -->
-
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject" ref="org.hisp.dhis.system.startup.StartupRoutineExecutor" />
<property name="targetMethod" value="addStartupRoutines" />
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SystemController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SystemController.java 2013-08-23 16:00:30 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SystemController.java 2013-09-01 21:38:52 +0000
@@ -28,13 +28,21 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
import org.hisp.dhis.api.utils.ContextUtils;
-import org.hisp.dhis.api.webdomain.SystemInfo;
import org.hisp.dhis.common.CodeGenerator;
import org.hisp.dhis.dxf2.metadata.ImportSummary;
import org.hisp.dhis.dxf2.utils.JacksonUtils;
import org.hisp.dhis.scheduling.TaskCategory;
import org.hisp.dhis.scheduling.TaskId;
+import org.hisp.dhis.system.SystemInfo;
+import org.hisp.dhis.system.SystemService;
import org.hisp.dhis.system.notification.Notification;
import org.hisp.dhis.system.notification.Notifier;
import org.hisp.dhis.system.scheduling.Scheduler;
@@ -46,12 +54,6 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@@ -68,6 +70,9 @@
private CurrentUserService currentUserService;
@Autowired
+ private SystemService systemService;
+
+ @Autowired
private Notifier notifier;
//--------------------------------------------------------------------------
@@ -140,8 +145,9 @@
@RequestMapping( value = "/info", method = RequestMethod.GET, produces = { "*/*", "application/json" } )
public void getSystemInfo( HttpServletRequest request, HttpServletResponse response ) throws IOException
{
- SystemInfo info = new SystemInfo();
+ SystemInfo info = systemService.getSystemInfo();
info.setContextPath( ContextUtils.getContextPath( request ) );
+ info.setUserAgent( request.getHeader( ContextUtils.HEADER_USER_AGENT ) );
JacksonUtils.toJson( response.getOutputStream(), info );
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/about/about.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/about/about.vm 2013-09-01 20:30:11 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/about/about.vm 2013-09-01 21:38:52 +0000
@@ -2,25 +2,25 @@
<dl>
<dt>$i18n.getString( "current_user" ):</dt><dd>$!currentUsername</dd>
- <dt>$i18n.getString( "version" ):</dt><dd>$!version</dd>
- <dt>$i18n.getString( "build_revision" ):</dt><dd>#if( $revision == '${revision}' ) NA #else $!revision #end</dd>
- <dt>$i18n.getString( "build_date" ):</dt><dd>$format.formatDateTime( $!buildTime )</dd>
+ <dt>$i18n.getString( "version" ):</dt><dd>$!info.version</dd>
+ <dt>$i18n.getString( "build_revision" ):</dt><dd>$!info.revision</dd>
+ <dt>$i18n.getString( "build_date" ):</dt><dd>$format.formatDateTime( $!info.buildTime )</dd>
<dt>$i18n.getString( "user_agent" ):</dt><dd>$!userAgent</dd>
+ <dt>$i18n.getString( "server_date" ):</dt><dd>$format.formatDateTime( $!info.serverDate )</dd>
+ <dt>$i18n.getString( "environment_variable" ):</dt><dd>$!info.environmentVariable</dd>
#if ( $currentUserIsSuper )
- <dt>$i18n.getString( "external_configuration_directory" ):</dt><dd>$!externalDirectory</dd>
- <dt>$i18n.getString( "environment_variable" ):</dt><dd>$!environmentVariable</dd>
- <dt>$i18n.getString( "database_type" ):</dt><dd>$!info.type</dd>
- <dt>$i18n.getString( "database_name" ):</dt><dd>$!info.name</dd>
- <dt>$i18n.getString( "database_user" ):</dt><dd>$!info.user</dd>
- <dt>$i18n.getString( "java_opts" ):</dt><dd>$!javaOpts</dd>
- <dt>$i18n.getString( "java_tmp_dir" ):</dt><dd>$!javaIoTmpDir</dd>
- <dt>$i18n.getString( "java_version" ):</dt><dd>$systemProperties.get( "java.version" )</dd>
- <dt>$i18n.getString( "java_vendor" ):</dt><dd>$systemProperties.get( "java.vendor" )</dd>
- <dt>$i18n.getString( "os_name" ):</dt><dd>$systemProperties.get( "os.name" )</dd>
- <dt>$i18n.getString( "os_architecture" ):</dt><dd>$systemProperties.get( "os.arch" )</dd>
- <dt>$i18n.getString( "os_version" ):</dt><dd>$systemProperties.get( "os.version" )</dd>
- <dt>$i18n.getString( "server_date" ):</dt><dd>$format.formatDateTime( $serverDate )</dd>
- <dt>$i18n.getString( "server_memory" ):</dt><dd>$memoryInfo</dd>
- <dt>$i18n.getString( "cpu_cores" ):</dt><dd>$cpuCores</dd>
+ <dt>$i18n.getString( "external_configuration_directory" ):</dt><dd>$!info.externalDirectory</dd>
+ <dt>$i18n.getString( "database_type" ):</dt><dd>$!info.databaseInfo.type</dd>
+ <dt>$i18n.getString( "database_name" ):</dt><dd>$!info.databaseInfo.name</dd>
+ <dt>$i18n.getString( "database_user" ):</dt><dd>$!info.databaseInfo.user</dd>
+ <dt>$i18n.getString( "java_opts" ):</dt><dd>$!info.javaOpts</dd>
+ <dt>$i18n.getString( "java_tmp_dir" ):</dt><dd>$!info.javaIoTmpDir</dd>
+ <dt>$i18n.getString( "java_version" ):</dt><dd>$!info.javaVersion</dd>
+ <dt>$i18n.getString( "java_vendor" ):</dt><dd>$!info.javaVendor</dd>
+ <dt>$i18n.getString( "os_name" ):</dt><dd>$!info.osName</dd>
+ <dt>$i18n.getString( "os_architecture" ):</dt><dd>$!info.osArchitecture</dd>
+ <dt>$i18n.getString( "os_version" ):</dt><dd>$!info.osVersion</dd>
+ <dt>$i18n.getString( "server_memory" ):</dt><dd>$!info.memoryInfo</dd>
+ <dt>$i18n.getString( "cpu_cores" ):</dt><dd>$!info.cpuCores</dd>
#end
</dl>
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/about/action/AboutAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/about/action/AboutAction.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/about/action/AboutAction.java 2013-09-01 21:38:52 +0000
@@ -28,26 +28,14 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.io.File;
-import java.io.InputStream;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Properties;
-
import javax.servlet.http.HttpServletRequest;
-import org.apache.commons.io.IOUtils;
import org.apache.struts2.ServletActionContext;
-import org.hisp.dhis.external.location.LocationManager;
-import org.hisp.dhis.external.location.LocationManagerException;
-import org.hisp.dhis.i18n.I18n;
-import org.hisp.dhis.system.database.DatabaseInfo;
-import org.hisp.dhis.system.database.DatabaseInfoProvider;
-import org.hisp.dhis.system.util.SystemUtils;
+import org.hisp.dhis.system.SystemInfo;
+import org.hisp.dhis.system.SystemService;
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.util.ContextUtils;
-import org.springframework.core.io.ClassPathResource;
+import org.springframework.beans.factory.annotation.Autowired;
import com.opensymphony.xwork2.Action;
@@ -61,108 +49,30 @@
// Dependencies
// -------------------------------------------------------------------------
- private LocationManager locationManager;
-
- public void setLocationManager( LocationManager locationManager )
- {
- this.locationManager = locationManager;
- }
-
- private DatabaseInfoProvider databaseInfoProvider;
-
- public void setDatabaseInfoProvider( DatabaseInfoProvider databaseInfoProvider )
- {
- this.databaseInfoProvider = databaseInfoProvider;
- }
-
+ @Autowired
+ private SystemService systemService;
+
+ @Autowired
private CurrentUserService currentUserService;
-
- public void setCurrentUserService( CurrentUserService currentUserService )
- {
- this.currentUserService = currentUserService;
- }
-
- private I18n i18n;
-
- public void setI18n( I18n i18n )
- {
- this.i18n = i18n;
- }
-
+
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
- private String version;
-
- public String getVersion()
- {
- return version;
- }
-
- private String revision;
-
- public String getRevision()
- {
- return revision;
- }
-
- private Date buildTime;
-
- public Date getBuildTime()
- {
- return buildTime;
- }
+ private SystemInfo info;
+ public SystemInfo getInfo()
+ {
+ return info;
+ }
+
private String userAgent;
public String getUserAgent()
{
return userAgent;
}
-
- private String environmentVariable;
-
- public String getEnvironmentVariable()
- {
- return environmentVariable;
- }
-
- private String javaIoTmpDir;
-
- public String getJavaIoTmpDir()
- {
- return javaIoTmpDir;
- }
-
- private String externalDirectory;
-
- public String getExternalDirectory()
- {
- return externalDirectory;
- }
-
- private DatabaseInfo info;
-
- public DatabaseInfo getInfo()
- {
- return info;
- }
-
- private String javaOpts;
-
- public String getJavaOpts()
- {
- return javaOpts;
- }
-
- private Properties systemProperties;
-
- public Properties getSystemProperties()
- {
- return systemProperties;
- }
-
+
private boolean currentUserIsSuper;
public boolean getCurrentUserIsSuper()
@@ -170,27 +80,6 @@
return currentUserIsSuper;
}
- private Date serverDate = new Date();
-
- public Date getServerDate()
- {
- return serverDate;
- }
-
- private String memoryInfo;
-
- public String getMemoryInfo()
- {
- return memoryInfo;
- }
-
- private int cpuCores;
-
- public int getCpuCores()
- {
- return cpuCores;
- }
-
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -198,94 +87,13 @@
public String execute()
throws Exception
{
- // ---------------------------------------------------------------------
- // Version
- // ---------------------------------------------------------------------
-
- ClassPathResource resource = new ClassPathResource( "build.properties" );
-
- if ( resource.isReadable() )
- {
- InputStream in = resource.getInputStream();
-
- try
- {
- Properties properties = new Properties();
-
- properties.load( in );
-
- version = properties.getProperty( "build.version" );
-
- revision = properties.getProperty( "build.revision" );
-
- String buildTime = properties.getProperty( "build.time" );
-
- DateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" );
-
- this.buildTime = dateFormat.parse( buildTime );
- }
- finally
- {
- IOUtils.closeQuietly( in );
- }
- }
-
+ info = systemService.getSystemInfo();
+
HttpServletRequest request = ServletActionContext.getRequest();
- // ---------------------------------------------------------------------
- // User agent
- // ---------------------------------------------------------------------
-
userAgent = request.getHeader( ContextUtils.HEADER_USER_AGENT );
-
- // ---------------------------------------------------------------------
- // External directory
- // ---------------------------------------------------------------------
-
- environmentVariable = locationManager.getEnvironmentVariable();
-
- try
- {
- File directory = locationManager.getExternalDirectory();
-
- externalDirectory = directory.getAbsolutePath();
- }
- catch ( LocationManagerException ex )
- {
- externalDirectory = i18n.getString( "not_set" );
- }
-
- // ---------------------------------------------------------------------
- // Database
- // ---------------------------------------------------------------------
-
- info = databaseInfoProvider.getDatabaseInfo();
-
- try
- {
- javaOpts = System.getenv( "JAVA_OPTS" );
- }
- catch ( SecurityException ex )
- {
- javaOpts = i18n.getString( "unknown" );
- }
-
- try
- {
- javaIoTmpDir = System.getProperty( "java.io.tmpdir" );
- }
- catch ( SecurityException ex )
- {
- javaOpts = i18n.getString( "unknown" );
- }
-
- systemProperties = System.getProperties();
currentUserIsSuper = currentUserService.currentUserIsSuper();
-
- memoryInfo = SystemUtils.getMemoryString();
-
- cpuCores = SystemUtils.getCpuCores();
return SUCCESS;
}
=== 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 2013-08-16 12:29:21 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2013-09-01 21:38:52 +0000
@@ -269,11 +269,7 @@
<!-- About -->
- <bean id="org.hisp.dhis.about.action.AboutAction" class="org.hisp.dhis.about.action.AboutAction" scope="prototype">
- <property name="locationManager" ref="locationManager" />
- <property name="databaseInfoProvider" ref="databaseInfoProvider" />
- <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
- </bean>
+ <bean id="org.hisp.dhis.about.action.AboutAction" class="org.hisp.dhis.about.action.AboutAction" scope="prototype" />
<bean id="org.hisp.dhis.about.action.HelpAction" class="org.hisp.dhis.about.action.HelpAction" scope="prototype">
<property name="localeManager" ref="org.hisp.dhis.i18n.locale.LocaleManager" />