← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21509: Code style

 

------------------------------------------------------------
revno: 21509
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-12-22 12:58:21 +0100
message:
  Code style
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/appmanager/DefaultAppManager.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-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	2015-12-22 11:50:21 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/appmanager/DefaultAppManager.java	2015-12-22 11:58:21 +0000
@@ -69,6 +69,8 @@
     implements AppManager
 {
     private static final Log log = LogFactory.getLog( DefaultDataValueService.class );
+    
+    private static final String MANIFEST_FILENAME = "manifest.webapp";
 
     /**
      * In-memory singleton list holding state for apps.
@@ -144,22 +146,22 @@
         {
             String baseUrl = config.getProperty( ConfigurationKey.SYSTEM_BASE_URL );
             
-            // ---------------------------------------------------------------------
-            // Parse zip file and it's manifest.webapp file.
-            // ---------------------------------------------------------------------
+            // -----------------------------------------------------------------
+            // Parse ZIP file and it's manifest.webapp file.
+            // -----------------------------------------------------------------
 
             ZipFile zip = new ZipFile( file );
 
-            ZipEntry entry = zip.getEntry( "manifest.webapp" );
+            ZipEntry entry = zip.getEntry( MANIFEST_FILENAME );
             InputStream inputStream = zip.getInputStream( entry );
             ObjectMapper mapper = new ObjectMapper();
             mapper.configure( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false );
 
             App app = mapper.readValue( inputStream, App.class );
 
-            // ---------------------------------------------------------------------
+            // -----------------------------------------------------------------
             // Check for namespace and if it's already taken by another app
-            // ---------------------------------------------------------------------
+            // -----------------------------------------------------------------
 
             String namespace = app.getActivities().getDhis().getNamespace();
             
@@ -170,16 +172,16 @@
                 return AppStatus.NAMESPACE_TAKEN;
             }
             
-            // ---------------------------------------------------------------------
-            // Delete if app is already installed.
-            // Assuming app-update, so no data is deleted.
-            // ---------------------------------------------------------------------
+            // -----------------------------------------------------------------
+            // Delete if app is already installed, assuming app update so no 
+            // data is deleted
+            // -----------------------------------------------------------------
 
             deleteApp( app.getName(), false );
 
-            // ---------------------------------------------------------------------
+            // -----------------------------------------------------------------
             // Unzip the app
-            // ---------------------------------------------------------------------
+            // -----------------------------------------------------------------
 
             log.info( "Installing app, namespace: " + namespace + ", base URL: " + baseUrl );
 
@@ -189,11 +191,11 @@
             unzip.setDest( new File( dest ) );
             unzip.execute();
 
-            // ---------------------------------------------------------------------
-            // Set dhis server location
-            // ---------------------------------------------------------------------
+            // -----------------------------------------------------------------
+            // Set DHIS 2 server location
+            // -----------------------------------------------------------------
 
-            File updateManifest = new File( dest + File.separator + "manifest.webapp" );
+            File updateManifest = new File( dest + File.separator + MANIFEST_FILENAME );
             App installedApp = mapper.readValue( updateManifest, App.class );
 
             if ( installedApp.getActivities() != null && installedApp.getActivities().getDhis() != null )
@@ -207,9 +209,9 @@
 
             log.info( "Installed app: " + app );
             
-            // ---------------------------------------------------------------------
+            // -----------------------------------------------------------------
             // Installation complete. Closing zip, reloading apps and return OK
-            // ---------------------------------------------------------------------
+            // -----------------------------------------------------------------
 
             zip.close();
 
@@ -262,7 +264,8 @@
                     String folderPath = getAppFolderPath() + File.separator + app.getFolderName();
                     FileUtils.forceDelete( new File( folderPath ) );
 
-                    // If deleteAppData is true and a namespace associated with the app exists, delete it.
+                    // Delete if deleteAppData is true and a namespace associated with the app exists
+                    
                     if ( deleteAppData && appNamespaces.containsValue( app ) )
                     {
                         appNamespaces.forEach( ( namespace, app1 ) -> {
@@ -379,8 +382,8 @@
                                 app.setFolderName( folder.getName() );
                                 appList.add( app );
 
-                                // Add namespace
                                 String appNamespace = app.getActivities().getDhis().getNamespace();
+                                
                                 if ( appNamespace != null )
                                 {
                                     appNamespaces.put( appNamespace, app );