← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21650: Apps. Removed the settings for configuring custum location for app server directory and URL. Rely...

 

------------------------------------------------------------
revno: 21650
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2016-01-07 20:01:46 +0100
message:
  Apps. Removed the settings for configuring custum location for app server directory and URL. Relying on serving apps from Web API from now on.
removed:
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/appmanager/
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/appmanager/DefaultAppManagerServiceTest.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppManager.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SettingKey.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/appmanager/DefaultAppManager.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AppController.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AppSettingsAction.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/AppManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppManager.java	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppManager.java	2016-01-07 19:01:46 +0000
@@ -108,13 +108,6 @@
     String getAppFolderPath();
 
     /**
-     * Saves the folder in which apps will be expanded
-     *
-     * @param appFolderPath
-     */
-    void setAppFolderPath( String appFolderPath );
-
-    /**
      * Gets the Base URL for accessing the apps
      *
      * @return the apps baseurl
@@ -122,13 +115,6 @@
     String getAppBaseUrl();
 
     /**
-     * Saves the base URL where apps are installed
-     *
-     * @param appBaseUrl
-     */
-    void setAppBaseUrl( String appBaseUrl );
-
-    /**
      * Returns the url of the app repository
      *
      * @return url of appstore

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SettingKey.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SettingKey.java	2016-01-07 08:13:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SettingKey.java	2016-01-07 19:01:46 +0000
@@ -109,8 +109,6 @@
     CUSTOM_CSS( "keyCustomCss" ),
     CALENDAR( "keyCalendar", "iso8601", String.class ),
     DATE_FORMAT( "keyDateFormat", "yyyy-MM-dd", String.class ),
-    APP_FOLDER_PATH( "appFolderPath" ),
-    APP_BASE_URL( "appBaseUrl" ),
     APP_STORE_URL( "appStoreUrl", "https://www.dhis2.org/appstore";, String.class ),
     APP_STORE_INDEX_URL( "appStoreIndexUrl", "https://s3-eu-west-1.amazonaws.com/dhis2-appstore/appstore.json";, String.class ),
     STYLE( "currentStyle", "light_blue/light_blue.css", String.class ),

=== 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-04 16:58:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/appmanager/DefaultAppManager.java	2016-01-07 19:01:46 +0000
@@ -51,6 +51,8 @@
 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;
 import org.hisp.dhis.setting.SettingKey;
 import org.hisp.dhis.setting.SystemSettingManager;
@@ -85,6 +87,8 @@
     @PostConstruct
     private void init()
     {
+        verifyAppFolder();
+        
         reloadApps();
     }
 
@@ -93,6 +97,9 @@
 
     @Autowired
     private CurrentUserService currentUserService;
+    
+    @Autowired
+    private LocationManager locationManager;
 
     @Autowired
     private KeyJsonValueService keyJsonValueService;
@@ -303,41 +310,23 @@
     @Override
     public String getAppFolderPath()
     {
-        return StringUtils.trimToNull( (String) appSettingManager.getSystemSetting( SettingKey.APP_FOLDER_PATH ) );
-    }
-
-    @Override
-    public void setAppFolderPath( String appFolderPath )
-    {
-        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( SettingKey.APP_FOLDER_PATH, appFolderPath );
+        try
+        {
+            return locationManager.getExternalDirectoryPath() + APPS_DIR;
+        }
+        catch ( LocationManagerException ex )
+        {
+            log.info( "Could not get app folder path, external directory not set" );
+            return null;
+        }
     }
 
     @Override
     public String getAppBaseUrl()
     {
-        return StringUtils.trimToNull( (String) appSettingManager.getSystemSetting( SettingKey.APP_BASE_URL ) );
-    }
-
-    @Override
-    public void setAppBaseUrl( String appBaseUrl )
-    {
-        appSettingManager.saveSystemSetting( SettingKey.APP_BASE_URL, appBaseUrl );
+        String baseUrl = (String) config.getProperty( ConfigurationKey.SYSTEM_BASE_URL );
+        
+        return baseUrl +  APPS_API_PATH;
     }
 
     @Override
@@ -438,4 +427,29 @@
     {
         return appNamespaces.get( namespace );
     }
+
+    /**
+     * Creates the app folder if it does not exist already.
+     */
+    private void verifyAppFolder()
+    {
+        String appFolderPath = getAppFolderPath();
+        
+        if ( appFolderPath != null && !appFolderPath.isEmpty() )
+        {
+            try
+            {
+                File folder = new File( appFolderPath );
+                
+                if ( !folder.exists() )
+                {
+                    FileUtils.forceMkdir( folder );
+                }
+            }
+            catch ( IOException ex )
+            {
+                log.error( ex.getMessage(), ex );
+            }
+        }
+    }
 }

=== removed directory 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/appmanager'
=== removed file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/appmanager/DefaultAppManagerServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/appmanager/DefaultAppManagerServiceTest.java	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/appmanager/DefaultAppManagerServiceTest.java	1970-01-01 00:00:00 +0000
@@ -1,117 +0,0 @@
-package org.hisp.dhis.appmanager;
-
-/*
- * Copyright (c) 2004-2016, 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 static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.util.List;
-
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- *
- * @author Saptarshi
- */
-public class DefaultAppManagerServiceTest
-{
-    /**
-     * Test of getAppFolderPath method, of class DefaultAppManagerService.
-     */
-    @Test
-    @Ignore
-    public void testGetAppFolderPath()
-    {
-        DefaultAppManager instance = new DefaultAppManager();
-        String expResult = "";
-        String result = instance.getAppFolderPath();
-        assertEquals( expResult, result );
-        // TODO review the generated test code and remove the default call to fail.
-        fail( "The test case is a prototype." );
-    }
-
-    /**
-     * Test of getAppStoreUrl method, of class DefaultAppManagerService.
-     */
-    @Test
-    @Ignore
-    public void testGetAppStoreUrl()
-    {
-        DefaultAppManager instance = new DefaultAppManager();
-        String expResult = "";
-        String result = instance.getAppStoreUrl();
-        assertEquals( expResult, result );
-        // TODO review the generated test code and remove the default call to fail.
-        fail( "The test case is a prototype." );
-    }
-
-    /**
-     * Test of getInstalledApps method, of class DefaultAppManagerService.
-     */
-    @Test
-    @Ignore
-    public void testGetInstalledApps()
-    {
-        DefaultAppManager instance = new DefaultAppManager();
-        List<App> expResult = null;
-        List<App> result = instance.getApps();
-        assertEquals( expResult, result );
-        // TODO review the generated test code and remove the default call to fail.
-        fail( "The test case is a prototype." );
-    }
-
-    /**
-     * Test of setAppFolderPath method, of class DefaultAppManagerService.
-     */
-    @Test
-    @Ignore
-    public void testSetAppFolderPath()
-    {
-        String appFolderPath = "";
-        DefaultAppManager instance = new DefaultAppManager();
-        instance.setAppFolderPath( appFolderPath );
-        // TODO review the generated test code and remove the default call to fail.
-        fail( "The test case is a prototype." );
-    }
-
-    /**
-     * Test of setAppStoreUrl method, of class DefaultAppManagerService.
-     */
-    @Test
-    @Ignore
-    public void testSetAppStoreUrl()
-    {
-        String appStoreUrl = "";
-        DefaultAppManager instance = new DefaultAppManager();
-        instance.setAppStoreUrl( appStoreUrl );
-        // TODO review the generated test code and remove the default call to fail.
-        fail( "The test case is a prototype." );
-    }
-}
\ No newline at end of file

=== 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-04 16:36:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AppController.java	2016-01-07 19:01:46 +0000
@@ -37,7 +37,6 @@
 import org.hisp.dhis.dxf2.render.DefaultRenderService;
 import org.hisp.dhis.dxf2.render.RenderService;
 import org.hisp.dhis.dxf2.webmessage.WebMessageException;
-import org.hisp.dhis.external.location.LocationManager;
 import org.hisp.dhis.hibernate.exception.ReadAccessDeniedException;
 import org.hisp.dhis.i18n.I18nManager;
 import org.hisp.dhis.setting.SettingKey;
@@ -79,9 +78,6 @@
     
     @Autowired
     private RenderService renderService;
-
-    @Autowired
-    private LocationManager locationManager;
     
     @Autowired
     private I18nManager i18nManager;
@@ -245,39 +241,14 @@
             throw new WebMessageException( WebMessageUtils.conflict( "No config specified" ) );
         }
 
-        String appBaseUrl = StringUtils.trimToNull( config.get( SettingKey.APP_BASE_URL.getName() ) );
-        String appFolderPath = StringUtils.trimToNull( config.get( SettingKey.APP_FOLDER_PATH.getName() ) );
         String appStoreUrl = StringUtils.trimToNull( config.get( SettingKey.APP_STORE_URL.getName() ) );
 
-        if ( appBaseUrl != null )
-        {
-            appManager.setAppBaseUrl( appBaseUrl );
-        }
-
-        if ( appFolderPath != null )
-        {
-            appManager.setAppFolderPath( appFolderPath );
-        }
-
         if ( appStoreUrl != null )
         {
             appManager.setAppStoreUrl( appStoreUrl );
         }
     }
-
-    @RequestMapping( value = "/config", method = RequestMethod.DELETE )
-    @PreAuthorize( "hasRole('ALL') or hasRole('M_dhis-web-maintenance-appmanager')" )
-    public void resetConfig( HttpServletRequest request )
-    {
-        String contextPath = ContextUtils.getContextPath( request );
-
-        String appFolderPath = locationManager.getExternalDirectoryPath() + AppManager.APPS_DIR;
-        String appBaseUrl = contextPath + AppManager.APPS_API_PATH;
-
-        appManager.setAppFolderPath( appFolderPath );
-        appManager.setAppBaseUrl( appBaseUrl );
-    }
-
+    
     //--------------------------------------------------------------------------
     // Helpers
     //--------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java	2016-01-07 19:01:46 +0000
@@ -56,7 +56,7 @@
     private static final Set<SettingKey> SETTINGS = Sets.newHashSet( SettingKey.APPLICATION_TITLE, SettingKey.APPLICATION_INTRO,
         SettingKey.APPLICATION_NOTIFICATION, SettingKey.APPLICATION_FOOTER, SettingKey.APPLICATION_RIGHT_FOOTER,
         SettingKey.FLAG, SettingKey.START_MODULE, SettingKey.MULTI_ORGANISATION_UNIT_FORMS, SettingKey.ACCOUNT_RECOVERY,
-        SettingKey.APP_BASE_URL, SettingKey.INSTANCE_BASE_URL, SettingKey.GOOGLE_ANALYTICS_UA, SettingKey.OPENID_PROVIDER,
+        SettingKey.INSTANCE_BASE_URL, SettingKey.GOOGLE_ANALYTICS_UA, SettingKey.OPENID_PROVIDER,
         SettingKey.OPENID_PROVIDER_LABEL, SettingKey.HELP_PAGE_LINK, SettingKey.REQUIRE_ADD_TO_VIEW, SettingKey.ALLOW_OBJECT_ASSIGNMENT,
         SettingKey.CALENDAR, SettingKey.DATE_FORMAT );
     

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AppSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AppSettingsAction.java	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AppSettingsAction.java	2016-01-07 19:01:46 +0000
@@ -91,8 +91,8 @@
 
         if ( appFolderPath == null || appFolderPath.isEmpty() )
         {
-            appFolderPath = locationManager.getExternalDirectoryPath() + AppManager.APPS_DIR;            
-            appManager.setAppFolderPath( appFolderPath );
+            appFolderPath = locationManager.getExternalDirectoryPath() + AppManager.APPS_DIR;
+            //appManager.setAppFolderPath( appFolderPath );
         }
         
         appBaseUrl = appManager.getAppBaseUrl();
@@ -101,7 +101,7 @@
         {
             String contextPath = ContextUtils.getContextPath( ServletActionContext.getRequest() );
             appBaseUrl = contextPath + AppManager.APPS_API_PATH;
-            appManager.setAppBaseUrl( appBaseUrl );
+            //appManager.setAppBaseUrl( appBaseUrl );
         }
                 
         appManager.reloadApps();