dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #42107
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21508: Introduced new configuration property 'system.base_url' which indicates base url to dhis. Used wh...
Merge authors:
Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 21508 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-12-22 12:50:21 +0100
message:
Introduced new configuration property 'system.base_url' which indicates base url to dhis. Used when installing apps.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/App.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppManager.java
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/appstore/AppStoreManager.java
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/appstore/DefaultAppStoreManager.java
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/scheduling/ResourceTableTask.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/scheduling/AnalyticsTableTask.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/appmanager/DefaultAppManager.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/scheduling/MonitoringTask.java
dhis-2/dhis-support/dhis-support-external/src/main/java/org/hisp/dhis/external/conf/ConfigurationKey.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AppController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/ContextUtils.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AddAppAction.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
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/App.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/App.java 2015-09-16 14:49:50 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/App.java 2015-12-22 11:50:21 +0000
@@ -277,6 +277,10 @@
@Override
public String toString()
{
- return "[" + name + " " + version + "]";
+ return "{" +
+ "\"version:\"" + version + "\", " +
+ "\"name:\"" + name + "\", " +
+ "\"launchPath:\"" + launchPath + "\" " +
+ "}";
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppManager.java 2015-12-21 20:17:43 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppManager.java 2015-12-22 11:50:21 +0000
@@ -71,10 +71,9 @@
*
* @param file the app file.
* @param fileName the name of the app file.
- * @param rootPath the root path of the instance.
* @throws IOException if the app manifest file could not be read.
*/
- AppStatus installApp( File file, String fileName, String rootPath )
+ AppStatus installApp( File file, String fileName )
throws IOException;
/**
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/appstore/AppStoreManager.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/appstore/AppStoreManager.java 2015-12-21 21:50:29 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/appstore/AppStoreManager.java 2015-12-22 11:50:21 +0000
@@ -30,6 +30,8 @@
import java.io.IOException;
+import org.hisp.dhis.appmanager.AppStatus;
+
/**
* @author Lars Helge Overland
*/
@@ -37,4 +39,6 @@
{
AppStore getAppStore()
throws IOException;
+
+ AppStatus installAppFromAppStore( String id );
}
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/appstore/DefaultAppStoreManager.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/appstore/DefaultAppStoreManager.java 2015-12-21 21:50:29 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/appstore/DefaultAppStoreManager.java 2015-12-22 11:50:21 +0000
@@ -55,7 +55,7 @@
@Autowired
private AppManager appManager;
-
+
// -------------------------------------------------------------------------
// AppStoreManager implementation
// -------------------------------------------------------------------------
@@ -67,8 +67,8 @@
return JacksonUtils.fromJson( input, AppStore.class );
}
-
- public AppStatus installAppFromAppstore( String id )
+
+ public AppStatus installAppFromAppStore( String id )
{
try
{
@@ -82,7 +82,7 @@
String filename = url.getFile();
- return appManager.installApp( getFile( url ), filename, null );
+ return appManager.installApp( getFile( url ), filename );
}
return AppStatus.NOT_FOUND;
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/scheduling/ResourceTableTask.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/scheduling/ResourceTableTask.java 2015-12-08 19:33:06 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/scheduling/ResourceTableTask.java 2015-12-22 11:50:21 +0000
@@ -92,14 +92,14 @@
}
catch ( RuntimeException ex )
{
- String systemId = config.getProperty( ConfigurationKey.SYSTEM_ID );
+ String baseUrl = config.getProperty( ConfigurationKey.SYSTEM_BASE_URL );
notifier.notify( taskId, NotificationLevel.ERROR, "Process failed: " + ex.getMessage(), true );
messageService.sendSystemNotification(
"Resource table process failed",
"Resource table process failed, please check the logs. Time: " + new DateTime().toString() + ". " +
- "System: " + systemId + " " +
+ "System: " + baseUrl + " " +
"Message: " + ex.getMessage() + " " +
"Cause: " + DebugUtils.getStackTrace( ex.getCause() ) );
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/scheduling/AnalyticsTableTask.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/scheduling/AnalyticsTableTask.java 2015-12-08 19:33:06 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/scheduling/AnalyticsTableTask.java 2015-12-22 11:50:21 +0000
@@ -168,14 +168,14 @@
}
catch ( RuntimeException ex )
{
- String systemId = config.getProperty( ConfigurationKey.SYSTEM_ID );
+ String baseUrl = config.getProperty( ConfigurationKey.SYSTEM_BASE_URL );
notifier.notify( taskId, ERROR, "Process failed: " + ex.getMessage(), true );
messageService.sendSystemNotification(
"Analytics table process failed",
"Analytics table process failed, please check the logs. Time: " + new DateTime().toString() + ". " +
- "System: " + systemId + " " +
+ "System: " + baseUrl + " " +
"Message: " + ex.getMessage() + " " +
"Cause: " + DebugUtils.getStackTrace( ex.getCause() ) );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/appmanager/DefaultAppManager.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/appmanager/DefaultAppManager.java 2015-12-08 19:33:06 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/appmanager/DefaultAppManager.java 2015-12-22 11:50:21 +0000
@@ -49,6 +49,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.datavalue.DefaultDataValueService;
+import org.hisp.dhis.external.conf.ConfigurationKey;
+import org.hisp.dhis.external.conf.DhisConfigurationProvider;
import org.hisp.dhis.keyjsonvalue.KeyJsonValueService;
import org.hisp.dhis.setting.SettingKey;
import org.hisp.dhis.setting.SystemSettingManager;
@@ -92,6 +94,9 @@
@Autowired
private KeyJsonValueService keyJsonValueService;
+
+ @Autowired
+ private DhisConfigurationProvider config;
// -------------------------------------------------------------------------
// AppManagerService implementation
@@ -133,11 +138,12 @@
}
@Override
- public AppStatus installApp( File file, String fileName, String rootPath )
+ public AppStatus installApp( File file, String fileName )
{
try
{
-
+ String baseUrl = config.getProperty( ConfigurationKey.SYSTEM_BASE_URL );
+
// ---------------------------------------------------------------------
// Parse zip file and it's manifest.webapp file.
// ---------------------------------------------------------------------
@@ -155,14 +161,15 @@
// Check for namespace and if it's already taken by another app
// ---------------------------------------------------------------------
- String appNamespace = app.getActivities().getDhis().getNamespace();
- if ( appNamespace != null && (this.appNamespaces.containsKey( appNamespace ) &&
- !app.equals( appNamespaces.get( appNamespace ) )) )
+ String namespace = app.getActivities().getDhis().getNamespace();
+
+ if ( namespace != null && ( this.appNamespaces.containsKey( namespace ) &&
+ !app.equals( appNamespaces.get( namespace ) ) ) )
{
zip.close();
return AppStatus.NAMESPACE_TAKEN;
}
-
+
// ---------------------------------------------------------------------
// Delete if app is already installed.
// Assuming app-update, so no data is deleted.
@@ -174,6 +181,8 @@
// Unzip the app
// ---------------------------------------------------------------------
+ log.info( "Installing app, namespace: " + namespace + ", base URL: " + baseUrl );
+
String dest = getAppFolderPath() + File.separator + fileName.substring( 0, fileName.lastIndexOf( '.' ) );
Unzip unzip = new Unzip();
unzip.setSrc( file );
@@ -191,11 +200,13 @@
{
if ( "*".equals( installedApp.getActivities().getDhis().getHref() ) )
{
- installedApp.getActivities().getDhis().setHref( rootPath );
+ installedApp.getActivities().getDhis().setHref( baseUrl );
mapper.writeValue( updateManifest, installedApp );
}
}
+ log.info( "Installed app: " + app );
+
// ---------------------------------------------------------------------
// Installation complete. Closing zip, reloading apps and return OK
// ---------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/scheduling/MonitoringTask.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/scheduling/MonitoringTask.java 2015-12-08 19:33:06 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/scheduling/MonitoringTask.java 2015-12-22 11:50:21 +0000
@@ -93,14 +93,14 @@
}
catch ( RuntimeException ex )
{
- String systemId = config.getProperty( ConfigurationKey.SYSTEM_ID );
+ String baseUrl = config.getProperty( ConfigurationKey.SYSTEM_BASE_URL );
notifier.notify( taskId, ERROR, "Process failed: " + ex.getMessage(), true );
messageService.sendSystemNotification(
"Monitoring process failed",
"Monitoring process failed, please check the logs. Time: " + new DateTime().toString() + ". " +
- "System: " + systemId + " " +
+ "System: " + baseUrl + " " +
"Message: " + ex.getMessage() + " " +
"Cause: " + DebugUtils.getStackTrace( ex.getCause() ) );
=== modified file 'dhis-2/dhis-support/dhis-support-external/src/main/java/org/hisp/dhis/external/conf/ConfigurationKey.java'
--- dhis-2/dhis-support/dhis-support-external/src/main/java/org/hisp/dhis/external/conf/ConfigurationKey.java 2015-11-23 09:51:36 +0000
+++ dhis-2/dhis-support/dhis-support-external/src/main/java/org/hisp/dhis/external/conf/ConfigurationKey.java 2015-12-22 11:50:21 +0000
@@ -33,7 +33,7 @@
*/
public enum ConfigurationKey
{
- SYSTEM_ID( "system.id" ),
+ SYSTEM_BASE_URL( "system.base_url", "http://localhost:8080/dhis" ),
SYSTEM_READ_ONLY_MODE( "system.read_only_mode", "off" ),
CONNECTION_DIALECT( "connection.dialect" ),
CONNECTION_DRIVER_CLASS( "connection.driver_class" ),
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AppController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AppController.java 2015-12-21 21:50:29 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AppController.java 2015-12-22 11:50:21 +0000
@@ -129,9 +129,7 @@
File tempFile = File.createTempFile( "IMPORT_", "_ZIP" );
file.transferTo( tempFile );
- String contextPath = ContextUtils.getContextPath( request );
-
- AppStatus status = appManager.installApp( tempFile, file.getOriginalFilename(), contextPath );
+ AppStatus status = appManager.installApp( tempFile, file.getOriginalFilename() );
if ( !status.ok() )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/ContextUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/ContextUtils.java 2015-12-14 21:53:09 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/ContextUtils.java 2015-12-22 10:39:58 +0000
@@ -181,7 +181,7 @@
public static HttpServletRequest getRequest()
{
- return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
+ return ( (ServletRequestAttributes) RequestContextHolder.getRequestAttributes() ).getRequest();
}
public static String getContextPath( HttpServletRequest request )
@@ -190,7 +190,7 @@
String xForwardedProto = request.getHeader( "X-Forwarded-Proto" );
String xForwardedPort = request.getHeader( "X-Forwarded-Port" );
- if ( xForwardedProto != null && (xForwardedProto.equalsIgnoreCase( "http" ) || xForwardedProto.equalsIgnoreCase( "https" )) )
+ if ( xForwardedProto != null && ( xForwardedProto.equalsIgnoreCase( "http" ) || xForwardedProto.equalsIgnoreCase( "https" ) ) )
{
builder.append( xForwardedProto );
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AddAppAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AddAppAction.java 2015-10-12 10:31:55 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AddAppAction.java 2015-12-22 11:50:21 +0000
@@ -35,15 +35,11 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
-import javax.servlet.http.HttpServletRequest;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.struts2.ServletActionContext;
import org.hisp.dhis.appmanager.AppManager;
import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.commons.util.StreamUtils;
-import org.hisp.dhis.webapi.utils.ContextUtils;
import org.springframework.beans.factory.annotation.Autowired;
import com.opensymphony.xwork2.Action;
@@ -105,8 +101,6 @@
public String execute()
throws Exception
{
- HttpServletRequest request = ServletActionContext.getRequest();
-
if ( file == null )
{
message = i18n.getString( "appmanager_no_file_specified" );
@@ -133,9 +127,7 @@
return FAILURE;
}
- String contextPath = ContextUtils.getContextPath( request );
-
- switch ( appManager.installApp( file, fileName, contextPath ) )
+ switch ( appManager.installApp( file, fileName ) )
{
case OK:
break;