dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24920
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12259: Apps, pushed delete app code to service layer
------------------------------------------------------------
revno: 12259
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-09-26 17:30:50 +0200
message:
Apps, pushed delete app code to service layer
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppManagerService.java
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/DeleteAppAction.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/AppManagerService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppManagerService.java 2013-08-23 15:56:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppManagerService.java 2013-09-26 15:30:50 +0000
@@ -67,6 +67,15 @@
* @return list of installed apps
*/
List<App> getInstalledApps();
+
+ /**
+ * Deletes the app with the given name.
+ * @param name the app name.
+ * @return true if the delete was successful, false if there is no app with
+ * the given name or if the app could not be removed from the file
+ * system.
+ */
+ boolean deleteApp( String name );
/**
* Returns the name of the specfic app folder
=== 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-09-26 14:59:56 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/appmanager/DefaultAppManagerService.java 2013-09-26 15:30:50 +0000
@@ -107,6 +107,29 @@
return appList;
}
+
+ public boolean deleteApp( String name )
+ {
+ for ( App app : getInstalledApps() )
+ {
+ if ( app.getName().equals( name ) )
+ {
+ try
+ {
+ String folderPath = getAppFolderPath() + File.separator + getAppFolderName( app );
+ FileUtils.forceDelete( new File( folderPath ) );
+ return true;
+ }
+ catch ( IOException ex )
+ {
+ log.error( "Could not delete app: " + name, ex );
+ return false;
+ }
+ }
+ }
+
+ return false;
+ }
@Override
public void setAppFolderPath( String 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-09-03 18:39:37 +0000
+++ dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/DeleteAppAction.java 2013-09-26 15:30:50 +0000
@@ -28,11 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.io.File;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.struts2.ServletActionContext;
-import org.hisp.dhis.appmanager.App;
import org.hisp.dhis.appmanager.AppManagerService;
import org.hisp.dhis.i18n.I18n;
import org.springframework.beans.factory.annotation.Autowired;
@@ -63,13 +58,20 @@
this.i18n = i18n;
}
+ private String appName;
+
+ public void setAppName( String appName )
+ {
+ this.appName = appName;
+ }
+
private String message;
public String getMessage()
{
return message;
}
-
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -78,21 +80,9 @@
public String execute()
throws Exception
{
- String appName = ServletActionContext.getRequest().getParameter( "appName" );
-
- if ( null != appName )
+ if ( appName != null && appManagerService.deleteApp( appName ) )
{
- // TODO: Move to AppManagerService
- for ( App app : appManagerService.getInstalledApps() )
- {
- if ( app.getName().equals( appName ) )
- {
- String folderPath = appManagerService.getAppFolderPath() + File.separator
- + appManagerService.getAppFolderName( app );
- FileUtils.forceDelete( new File( folderPath ) );
- message = i18n.getString( "appmanager_delete_success" );
- }
- }
+ message = i18n.getString( "appmanager_delete_success" );
}
return SUCCESS;