=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/appmanager/DefaultAppManagerService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/appmanager/DefaultAppManagerService.java 2013-05-23 06:17:02 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/appmanager/DefaultAppManagerService.java 2013-05-28 15:50:33 +0000 @@ -37,6 +37,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import static org.hisp.dhis.appmanager.AppManagerService.KEY_APP_FOLDER_PATH; import org.hisp.dhis.datavalue.DefaultDataValueService; import org.hisp.dhis.setting.SystemSettingManager; import org.springframework.beans.factory.annotation.Autowired; @@ -109,19 +110,21 @@ @Override public void setAppFolderPath( String appFolderPath ) { - try - { - File folder = new File( appFolderPath ); - if ( !folder.exists() ) - { - FileUtils.forceMkdir( folder ); - } - } - catch ( IOException ex ) - { - log.error( ex.getLocalizedMessage(), ex ); - } - + if(!appFolderPath.isEmpty()) + { + try + { + File folder = new File( appFolderPath ); + if ( !folder.exists() ) + { + FileUtils.forceMkdir( folder ); + } + } + catch ( IOException ex ) + { + log.error( ex.getLocalizedMessage(), ex ); + } + } appSettingManager.saveSystemSetting( KEY_APP_FOLDER_PATH, appFolderPath ); } === modified file 'dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AddAppAction.java' --- dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AddAppAction.java 2013-05-27 07:31:56 +0000 +++ dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AddAppAction.java 2013-05-28 15:50:33 +0000 @@ -122,7 +122,7 @@ { ZipFile zip = new ZipFile( file ); ZipEntry entry = zip.getEntry( "manifest.webapp" ); - + if ( null != entry ) { InputStream inputStream = zip.getInputStream( entry ); @@ -162,7 +162,7 @@ installedApp.getActivities().getDhis().setHref( rootPath ); mapper.writeValue( updateManifest, installedApp ); } - + zip.close(); message = i18n.getString( "appmanager_install_success" ); } === modified file 'dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AppListAction.java' --- dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AppListAction.java 2013-05-28 08:27:16 +0000 +++ dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AppListAction.java 2013-05-28 15:50:33 +0000 @@ -35,6 +35,9 @@ import org.springframework.beans.factory.annotation.Autowired; import com.opensymphony.xwork2.Action; +import javax.servlet.http.HttpServletRequest; +import org.apache.struts2.ServletActionContext; +import org.hisp.dhis.util.ContextUtils; /** * @author Saptarshi Purkayastha @@ -67,6 +70,30 @@ return appFolderNames; } + //TODO: create settings to set for external server like Apache2/nginx + // Should be a per-app setting + private String appsRootUrl = new String(); + + public String getAppsRootUrl() + { + HttpServletRequest request = ServletActionContext.getRequest(); + String realPath = ServletActionContext.getServletContext().getRealPath( "/" ); + String appFolderPath = appManagerService.getAppFolderPath(); + String baseUrl = ContextUtils.getBaseUrl( request ); + String contextPath = request.getContextPath(); + if ( !contextPath.isEmpty() ) + { + appsRootUrl = baseUrl.substring( 0, baseUrl.length() - 1 ) + request.getContextPath() + "/" + + ((appFolderPath.replace( "//", "/" )).replace( realPath, "" )).replace( '\\', '/' ); + } + else + { + appsRootUrl = baseUrl.substring( 0, baseUrl.length() - 1 ) + + ((appFolderPath.replace( "//", "/" )).replace( realPath, "" )).replace( '\\', '/' ); + } + return appsRootUrl; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AppSettingsAction.java' --- dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AppSettingsAction.java 2013-05-27 07:31:56 +0000 +++ dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AppSettingsAction.java 2013-05-28 15:50:33 +0000 @@ -65,7 +65,15 @@ if ( null == appFolderPath || appFolderPath.isEmpty() ) { - appFolderPath = ServletActionContext.getServletContext().getRealPath( "/" ) + File.separatorChar + "apps"; + String realPath = ServletActionContext.getServletContext().getRealPath( "/" ); + if ( realPath.endsWith( "/" ) || realPath.endsWith( "\\" ) ) + { + appFolderPath = realPath + "apps"; + } + else + { + appFolderPath = realPath + File.separatorChar + "apps"; + } appManagerService.setAppFolderPath( appFolderPath ); } === modified file 'dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/DeleteAppAction.java' --- dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/DeleteAppAction.java 2013-05-27 07:31:56 +0000 +++ dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/DeleteAppAction.java 2013-05-28 15:50:33 +0000 @@ -59,7 +59,7 @@ // ------------------------------------------------------------------------- // Input & Output // ------------------------------------------------------------------------- - + private I18n i18n; public void setI18n( I18n i18n ) @@ -83,7 +83,7 @@ throws Exception { String appName = ServletActionContext.getRequest().getParameter( "appName" ); - + if ( null != appName ) { // TODO: Move to AppManagerService @@ -98,7 +98,7 @@ } } } - + return SUCCESS; } } === modified file 'dhis-2/dhis-web/dhis-web-appmanager/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-appmanager/src/main/resources/struts.xml 2013-05-27 07:31:56 +0000 +++ dhis-2/dhis-web/dhis-web-appmanager/src/main/resources/struts.xml 2013-05-28 15:50:33 +0000 @@ -40,6 +40,7 @@ /dhis-web-appmanager/getApps.vm /dhis-web-appmanager/menu.vm javascript/jquery.form.js,javascript/uploadApp.js + F_SYSTEM_SETTING @@ -48,8 +49,8 @@ /dhis-web-appmanager/appSettings.vm /dhis-web-appmanager/menu.vm plainTextError - F_SYSTEM_SETTING javascript/jquery.form.js,javascript/deleteApp.js + F_SYSTEM_SETTING === modified file 'dhis-2/dhis-web/dhis-web-appmanager/src/main/webapp/dhis-web-appmanager/index.vm' --- dhis-2/dhis-web/dhis-web-appmanager/src/main/webapp/dhis-web-appmanager/index.vm 2013-05-28 08:27:16 +0000 +++ dhis-2/dhis-web/dhis-web-appmanager/src/main/webapp/dhis-web-appmanager/index.vm 2013-05-28 15:50:33 +0000 @@ -12,9 +12,9 @@
  • $i18n.getString( "appmanager_you_have_no_apps_installed" )
  • #else #foreach( $app in $appList ) -
  • +
  • - + ${app.name}
    === modified file 'dhis-2/dhis-web/dhis-web-appmanager/src/main/webapp/dhis-web-appmanager/menu.vm' --- dhis-2/dhis-web/dhis-web-appmanager/src/main/webapp/dhis-web-appmanager/menu.vm 2013-05-23 00:18:55 +0000 +++ dhis-2/dhis-web/dhis-web-appmanager/src/main/webapp/dhis-web-appmanager/menu.vm 2013-05-28 15:50:33 +0000 @@ -1,6 +1,8 @@

    $i18n.getString( "dhis-web-appmanager" )