← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18035: Apps, added reset apps cinfig method

 

------------------------------------------------------------
revno: 18035
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-01-16 20:19:13 +0100
message:
  Apps, added reset apps cinfig method
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AppController.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-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-01-16 19:07:36 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AppController.java	2015-01-16 19:19:13 +0000
@@ -44,6 +44,7 @@
 import org.hisp.dhis.appmanager.AppManager;
 import org.hisp.dhis.dxf2.render.RenderService;
 import org.hisp.dhis.dxf2.utils.JacksonUtils;
+import org.hisp.dhis.external.location.LocationManager;
 import org.hisp.dhis.hibernate.exception.ReadAccessDeniedException;
 import org.hisp.dhis.system.util.DateUtils;
 import org.hisp.dhis.webapi.utils.ContextUtils;
@@ -82,6 +83,9 @@
     
     @Autowired
     private RenderService renderService;
+    
+    @Autowired
+    private LocationManager locationManager;
 
     private ResourceLoader resourceLoader = new DefaultResourceLoader();
 
@@ -237,7 +241,20 @@
         {
             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