dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #42480
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21714: App manager. Removed the need for the base URL config.
------------------------------------------------------------
revno: 21714
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2016-01-13 16:47:42 +0100
message:
App manager. Removed the need for the base URL config.
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/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/controller/ConfigurationController.java
dhis-2/dhis-web/dhis-web-commons/pom.xml
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/about/action/RedirectAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/authority/AppsSystemAuthoritiesProvider.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/interceptor/XWorkPortalModuleInterceptor.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/menu/action/GetModulesAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/DefaultModuleManager.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/ModuleManager.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 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/App.java 2016-01-13 15:47:42 +0000
@@ -84,23 +84,30 @@
private String folderName;
@JsonProperty
+ private String launchUrl;
+
+ @JsonIgnore
private String baseUrl;
// -------------------------------------------------------------------------
// Logic
// -------------------------------------------------------------------------
- @JsonProperty
- public String getLaunchUrl()
+ /**
+ * Initializes the app. Sets the launchUrl property.
+ *
+ * @param contextPath the context path of this instance.
+ */
+ public void init( String contextPath )
{
- if ( baseUrl != null && folderName != null && launchPath != null )
+ this.baseUrl = contextPath + "/api/apps";
+
+ if ( contextPath != null && folderName != null && launchPath != null )
{
- return baseUrl + "/" + folderName + "/"+ launchPath;
+ launchUrl = baseUrl + "/" + folderName + "/" + launchPath;
}
-
- return null;
}
-
+
/**
* Alias for folder name.
*/
@@ -224,6 +231,16 @@
this.folderName = folderName;
}
+ public String getLaunchUrl()
+ {
+ return launchUrl;
+ }
+
+ public void setLaunchUrl( String launchUrl )
+ {
+ this.launchUrl = launchUrl;
+ }
+
public String getBaseUrl()
{
return baseUrl;
=== 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 2016-01-07 19:01:46 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppManager.java 2016-01-13 15:47:42 +0000
@@ -47,24 +47,27 @@
/**
* Returns a list of all the installed apps at @see getAppFolderPath
*
+ * @param contextPath the context path of this instance.
* @return list of installed apps
*/
- List<App> getApps();
+ List<App> getApps( String contextPath );
/**
* Returns the app with the given key (folder name).
*
* @param key the app key.
+ * @param contextPath the context path of this instance.
* @return the app with the given key.
*/
- App getApp( String key );
+ App getApp( String key, String contextPath );
/**
* Returns apps which are accessible to the current user.
*
+ * @param contextPath the context path of this instance.
* @return apps which are accessible to the current user.
*/
- List<App> getAccessibleApps();
+ List<App> getAccessibleApps( String contextPath );
/**
* Installs the app.
@@ -108,13 +111,6 @@
String getAppFolderPath();
/**
- * Gets the Base URL for accessing the apps
- *
- * @return the apps baseurl
- */
- String getAppBaseUrl();
-
- /**
* Returns the url of the app repository
*
* @return url of appstore
=== 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 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/scheduling/ResourceTableTask.java 2016-01-13 15:47:42 +0000
@@ -31,8 +31,6 @@
import java.util.Date;
import org.hisp.dhis.commons.util.DebugUtils;
-import org.hisp.dhis.external.conf.ConfigurationKey;
-import org.hisp.dhis.external.conf.DhisConfigurationProvider;
import org.hisp.dhis.message.MessageService;
import org.hisp.dhis.resourcetable.ResourceTableService;
import org.hisp.dhis.scheduling.TaskId;
@@ -62,9 +60,6 @@
@Autowired
private SystemSettingManager systemSettingManager;
- @Autowired
- private DhisConfigurationProvider config;
-
private TaskId taskId;
public void setTaskId( TaskId taskId )
@@ -92,14 +87,14 @@
}
catch ( RuntimeException ex )
{
- String baseUrl = config.getProperty( ConfigurationKey.SYSTEM_BASE_URL );
+ String title = (String) systemSettingManager.getSystemSetting( SettingKey.APPLICATION_TITLE );
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: " + baseUrl + " " +
+ "System: " + title + " " +
"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 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/scheduling/AnalyticsTableTask.java 2016-01-13 15:47:42 +0000
@@ -39,8 +39,6 @@
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.analytics.AnalyticsTableService;
import org.hisp.dhis.commons.util.DebugUtils;
-import org.hisp.dhis.external.conf.ConfigurationKey;
-import org.hisp.dhis.external.conf.DhisConfigurationProvider;
import org.hisp.dhis.message.MessageService;
import org.hisp.dhis.scheduling.TaskId;
import org.hisp.dhis.security.NoSecurityContextRunnable;
@@ -84,9 +82,6 @@
@Autowired
private SystemSettingManager systemSettingManager;
- @Autowired
- private DhisConfigurationProvider config;
-
private Integer lastYears;
public void setLastYears( Integer lastYears )
@@ -168,14 +163,14 @@
}
catch ( RuntimeException ex )
{
- String baseUrl = config.getProperty( ConfigurationKey.SYSTEM_BASE_URL );
+ String title = (String) systemSettingManager.getSystemSetting( SettingKey.APPLICATION_TITLE );
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: " + baseUrl + " " +
+ "System: " + title + " " +
"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 2016-01-07 19:01:46 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/appmanager/DefaultAppManager.java 2016-01-13 15:47:42 +0000
@@ -49,8 +49,6 @@
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.external.location.LocationManager;
import org.hisp.dhis.external.location.LocationManagerException;
import org.hisp.dhis.keyjsonvalue.KeyJsonValueService;
@@ -104,30 +102,22 @@
@Autowired
private KeyJsonValueService keyJsonValueService;
- @Autowired
- private DhisConfigurationProvider config;
-
// -------------------------------------------------------------------------
// AppManagerService implementation
// -------------------------------------------------------------------------
@Override
- public List<App> getApps()
+ public List<App> getApps( String contextPath )
{
- String baseUrl = getAppBaseUrl();
-
- for ( App app : apps )
- {
- app.setBaseUrl( baseUrl );
- }
-
+ apps.forEach( a -> a.init( contextPath ) );
+
return apps;
}
@Override
- public App getApp( String key )
+ public App getApp( String key, String contextPath )
{
- List<App> apps = getApps();
+ List<App> apps = getApps( contextPath );
for ( App app : apps )
{
@@ -141,25 +131,18 @@
}
@Override
- public List<App> getAccessibleApps()
+ public List<App> getAccessibleApps( String contextPath )
{
User user = currentUserService.getCurrentUser();
- return getApps().stream().filter( a -> this.isAccessible( a, user ) ).collect( Collectors.toList() );
+ return getApps( contextPath ).stream().filter( a -> this.isAccessible( a, user ) ).collect( Collectors.toList() );
}
@Override
public AppStatus installApp( File file, String fileName )
{
try
- {
- String baseUrl = config.getProperty( ConfigurationKey.SYSTEM_BASE_URL );
-
- if ( baseUrl == null )
- {
- return AppStatus.MISSING_SYSTEM_BASE_URL;
- }
-
+ {
// -----------------------------------------------------------------
// Parse ZIP file and it's manifest.webapp file.
// -----------------------------------------------------------------
@@ -197,7 +180,7 @@
// Unzip the app
// -----------------------------------------------------------------
- log.info( "Installing app, namespace: " + namespace + ", base URL: " + baseUrl );
+ log.info( "Installing app, namespace: " + namespace );
String dest = getAppFolderPath() + File.separator + fileName.substring( 0, fileName.lastIndexOf( '.' ) );
Unzip unzip = new Unzip();
@@ -205,22 +188,6 @@
unzip.setDest( new File( dest ) );
unzip.execute();
- // -----------------------------------------------------------------
- // Set DHIS 2 server location
- // -----------------------------------------------------------------
-
- File updateManifest = new File( dest + File.separator + MANIFEST_FILENAME );
- App installedApp = mapper.readValue( updateManifest, App.class );
-
- if ( installedApp.getActivities() != null && installedApp.getActivities().getDhis() != null )
- {
- if ( "*".equals( installedApp.getActivities().getDhis().getHref() ) )
- {
- installedApp.getActivities().getDhis().setHref( baseUrl );
- mapper.writeValue( updateManifest, installedApp );
- }
- }
-
log.info( "Installed app: " + app );
// -----------------------------------------------------------------
@@ -255,7 +222,7 @@
@Override
public boolean exists( String appName )
{
- for ( App app : getApps() )
+ for ( App app : getApps( null ) )
{
if ( app.getName().equals( appName ) || app.getFolderName().equals( appName ) )
{
@@ -269,7 +236,7 @@
@Override
public boolean deleteApp( String name, boolean deleteAppData )
{
- for ( App app : getApps() )
+ for ( App app : getApps( null ) )
{
if ( app.getName().equals( name ) || app.getFolderName().equals( name ) )
{
@@ -322,14 +289,6 @@
}
@Override
- public String getAppBaseUrl()
- {
- String baseUrl = (String) config.getProperty( ConfigurationKey.SYSTEM_BASE_URL );
-
- return baseUrl + APPS_API_PATH;
- }
-
- @Override
public String getAppStoreUrl()
{
return StringUtils.trimToNull( (String) appSettingManager.getSystemSetting( SettingKey.APP_STORE_URL ) );
@@ -341,10 +300,6 @@
appSettingManager.saveSystemSetting( SettingKey.APP_STORE_URL, appStoreUrl );
}
- // -------------------------------------------------------------------------
- // Supportive methods
- // -------------------------------------------------------------------------
-
/**
* Sets the list of apps with detected apps from the file system.
*/
@@ -428,6 +383,10 @@
return appNamespaces.get( namespace );
}
+ // -------------------------------------------------------------------------
+ // Supportive methods
+ // -------------------------------------------------------------------------
+
/**
* Creates the app folder if it does not exist already.
*/
=== 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 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/scheduling/MonitoringTask.java 2016-01-13 15:47:42 +0000
@@ -34,8 +34,6 @@
import java.util.Date;
import org.hisp.dhis.commons.util.DebugUtils;
-import org.hisp.dhis.external.conf.ConfigurationKey;
-import org.hisp.dhis.external.conf.DhisConfigurationProvider;
import org.hisp.dhis.message.MessageService;
import org.hisp.dhis.scheduling.TaskId;
import org.hisp.dhis.setting.SettingKey;
@@ -64,9 +62,6 @@
@Autowired
private SystemSettingManager systemSettingManager;
- @Autowired
- private DhisConfigurationProvider config;
-
private TaskId taskId;
public void setTaskId( TaskId taskId )
@@ -93,14 +88,14 @@
}
catch ( RuntimeException ex )
{
- String baseUrl = config.getProperty( ConfigurationKey.SYSTEM_BASE_URL );
+ String title = (String) systemSettingManager.getSystemSetting( SettingKey.APPLICATION_TITLE );
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: " + baseUrl + " " +
+ "System: " + title + " " +
"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 2016-01-06 19:24:34 +0000
+++ dhis-2/dhis-support/dhis-support-external/src/main/java/org/hisp/dhis/external/conf/ConfigurationKey.java 2016-01-13 15:47:42 +0000
@@ -33,7 +33,6 @@
*/
public enum ConfigurationKey
{
- SYSTEM_BASE_URL( "system.base_url" ),
SYSTEM_READ_ONLY_MODE( "system.read_only_mode", "off" ),
ENCRYPTION_PASSWORD( "encryption.password", "" ),
CONNECTION_DIALECT( "connection.dialect" ),
=== 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 2016-01-07 19:01:46 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AppController.java 2016-01-13 15:47:42 +0000
@@ -90,14 +90,16 @@
@RequestMapping( method = RequestMethod.GET, produces = ContextUtils.CONTENT_TYPE_JSON )
public void getApps( @RequestParam( required = false ) String key,
- HttpServletResponse response )
+ HttpServletRequest request, HttpServletResponse response )
throws IOException
{
+ String contextPath = ContextUtils.getContextPath( request );
+
List<App> apps = new ArrayList<>();
if ( key != null )
{
- App app = appManager.getApp( key );
+ App app = appManager.getApp( key, contextPath );
if ( app == null )
{
@@ -109,7 +111,7 @@
}
else
{
- apps = appManager.getApps();
+ apps = appManager.getApps( contextPath );
}
renderService.toJson( response.getOutputStream(), apps );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ConfigurationController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ConfigurationController.java 2016-01-06 19:24:34 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ConfigurationController.java 2016-01-13 15:47:42 +0000
@@ -337,13 +337,7 @@
configurationService.setConfiguration( config );
}
-
- @RequestMapping( value = "/systemBaseUrl", method = RequestMethod.GET )
- public String getSystemBaseUrl( Model model, HttpServletRequest request )
- {
- return setModel( model, config.getProperty( ConfigurationKey.SYSTEM_BASE_URL ) );
- }
-
+
@RequestMapping( value = "/systemReadOnlyMode", method = RequestMethod.GET )
public String getSystemReadOnlyMode( Model model, HttpServletRequest request )
{
=== modified file 'dhis-2/dhis-web/dhis-web-commons/pom.xml'
--- dhis-2/dhis-web/dhis-web-commons/pom.xml 2015-10-20 22:50:17 +0000
+++ dhis-2/dhis-web/dhis-web-commons/pom.xml 2016-01-13 15:47:42 +0000
@@ -43,6 +43,10 @@
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-support-system</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-web-api</artifactId>
+ </dependency>
<!-- Web -->
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/about/action/RedirectAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/about/action/RedirectAction.java 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/about/action/RedirectAction.java 2016-01-13 15:47:42 +0000
@@ -29,10 +29,13 @@
*/
import com.opensymphony.xwork2.Action;
+
+import org.apache.struts2.ServletActionContext;
import org.hisp.dhis.appmanager.App;
import org.hisp.dhis.appmanager.AppManager;
import org.hisp.dhis.setting.SettingKey;
import org.hisp.dhis.setting.SystemSettingManager;
+import org.hisp.dhis.webapi.utils.ContextUtils;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
@@ -62,11 +65,13 @@
{
String startModule = (String) systemSettingManager.getSystemSetting( SettingKey.START_MODULE );
+ String contextPath = (String) ContextUtils.getContextPath( ServletActionContext.getRequest() );
+
if ( startModule != null && !startModule.trim().isEmpty() )
{
if ( startModule.startsWith( "app:" ) )
{
- List<App> apps = appManager.getApps();
+ List<App> apps = appManager.getApps( contextPath );
for ( App app : apps )
{
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/authority/AppsSystemAuthoritiesProvider.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/authority/AppsSystemAuthoritiesProvider.java 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/authority/AppsSystemAuthoritiesProvider.java 2016-01-13 15:47:42 +0000
@@ -46,7 +46,7 @@
@Override
public Collection<String> getSystemAuthorities()
{
- return appManager.getApps().stream()
+ return appManager.getApps( null ).stream()
.filter( app -> !StringUtils.isEmpty( app.getName() ) )
.map( app -> "See " + app.getName().trim() )
.collect( Collectors.toList() );
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/interceptor/XWorkPortalModuleInterceptor.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/interceptor/XWorkPortalModuleInterceptor.java 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/interceptor/XWorkPortalModuleInterceptor.java 2016-01-13 15:47:42 +0000
@@ -30,6 +30,9 @@
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
+
+import org.apache.struts2.ServletActionContext;
+import org.hisp.dhis.webapi.utils.ContextUtils;
import org.hisp.dhis.webportal.module.ModuleManager;
import java.util.HashMap;
@@ -77,9 +80,11 @@
public String intercept( ActionInvocation actionInvocation )
throws Exception
{
+ String contextPath = ContextUtils.getContextPath( ServletActionContext.getRequest() );
+
Map<String, Object> handle = new HashMap<>( 2 );
- handle.put( KEY_MENU_MODULES, moduleManager.getAccessibleMenuModulesAndApps() );
+ handle.put( KEY_MENU_MODULES, moduleManager.getAccessibleMenuModulesAndApps( contextPath ) );
actionInvocation.getStack().push( handle );
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/menu/action/GetModulesAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/menu/action/GetModulesAction.java 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/menu/action/GetModulesAction.java 2016-01-13 15:47:42 +0000
@@ -32,8 +32,10 @@
import java.util.Comparator;
import java.util.List;
+import org.apache.struts2.ServletActionContext;
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.user.User;
+import org.hisp.dhis.webapi.utils.ContextUtils;
import org.hisp.dhis.webportal.module.Module;
import org.hisp.dhis.webportal.module.ModuleManager;
import org.springframework.beans.factory.annotation.Autowired;
@@ -63,7 +65,9 @@
public String execute()
throws Exception
{
- modules = manager.getAccessibleMenuModulesAndApps();
+ String contextPath = ContextUtils.getContextPath( ServletActionContext.getRequest() );
+
+ modules = manager.getAccessibleMenuModulesAndApps( contextPath );
User user = currentUserService.getCurrentUser();
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/DefaultModuleManager.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/DefaultModuleManager.java 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/DefaultModuleManager.java 2016-01-13 15:47:42 +0000
@@ -152,10 +152,10 @@
}
@Override
- public List<Module> getAccessibleMenuModulesAndApps()
+ public List<Module> getAccessibleMenuModulesAndApps( String contextPath )
{
List<Module> modules = getAccessibleMenuModules();
- List<App> apps = appManager.getAccessibleApps();
+ List<App> apps = appManager.getAccessibleApps( contextPath );
modules.addAll( apps.stream().map( Module::getModule ).collect( Collectors.toList() ) );
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/ModuleManager.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/ModuleManager.java 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/ModuleManager.java 2016-01-13 15:47:42 +0000
@@ -47,7 +47,7 @@
List<Module> getAccessibleMenuModules();
- List<Module> getAccessibleMenuModulesAndApps();
+ List<Module> getAccessibleMenuModulesAndApps( String contextPath );
Collection<Module> getAllModules();