← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11055: Fix permissions. Menu on privileges. Fix apps url

 

------------------------------------------------------------
revno: 11055
committer: Saptarshi <sunbiz@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-05-28 17:50:33 +0200
message:
  Fix permissions. Menu on privileges. Fix apps url
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/appmanager/DefaultAppManagerService.java
  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/AppListAction.java
  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/DeleteAppAction.java
  dhis-2/dhis-web/dhis-web-appmanager/src/main/resources/struts.xml
  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/menu.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-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 @@
       <param name="page">/dhis-web-appmanager/getApps.vm</param>
       <param name="menu">/dhis-web-appmanager/menu.vm</param>
       <param name="javascripts">javascript/jquery.form.js,javascript/uploadApp.js</param>
+      <param name="requiredAuthorities">F_SYSTEM_SETTING</param>
     </action>
     
     <action name="appSettings" class="org.hisp.dhis.appmanager.action.AppSettingsAction">
@@ -48,8 +49,8 @@
       <param name="page">/dhis-web-appmanager/appSettings.vm</param>
       <param name="menu">/dhis-web-appmanager/menu.vm</param>
       <param name="onExceptionReturn">plainTextError</param>
-      <param name="requiredAuthorities">F_SYSTEM_SETTING</param>
       <param name="javascripts">javascript/jquery.form.js,javascript/deleteApp.js</param>
+      <param name="requiredAuthorities">F_SYSTEM_SETTING</param>
     </action>
     
   </package>

=== 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 @@
 	<li style="margin-left: 15px; margin-top: 6px;">$i18n.getString( "appmanager_you_have_no_apps_installed" )</li>
 #else
     #foreach( $app in $appList )
-    <li class="introItem" onclick="window.location.href='/apps/$appFolderNames.get($foreach.index)/$app.launchPath'">
+    <li class="introItem" onclick="window.location.href='$appsRootUrl/$appFolderNames.get($foreach.index)/$app.launchPath'">
         <span class="introItemHeader">
-            <img style="float:left; margin-right:15px" src="/apps/$appFolderNames.get($foreach.index)/$app.icons.icon48">
+            <img style="float:left; margin-right:15px" src="$appsRootUrl/$appFolderNames.get($foreach.index)/$app.icons.icon48">
             ${app.name}
         </span>
         <br>

=== 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 @@
 <h2>$i18n.getString( "dhis-web-appmanager" )</h2>
 <ul>
     <li><a href="appList.action">$i18n.getString( "appmanager_list_app" )</a></li>
+#if( $auth.hasAccess( "dhis-web-appmanager", "appSettings" ) )
     <li><a href="appSettings.action">$i18n.getString( "appmanager_settings" )</a></li>
     <li><a href="appStore.action">$i18n.getString( "appmanager_go" )</a></li>
+#end
 </ul>