dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24925
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12263: Apps, adding property folderName to App instead of maintaining list with state in service
------------------------------------------------------------
revno: 12263
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-09-26 18:53:50 +0200
message:
Apps, adding property folderName to App instead of maintaining list with state in service
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/App.java
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/AppListAction.java
dhis-2/dhis-web/dhis-web-appmanager/src/main/webapp/dhis-web-appmanager/index.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-api/src/main/java/org/hisp/dhis/appmanager/App.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/App.java 2013-08-23 15:56:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/App.java 2013-09-26 16:53:50 +0000
@@ -75,10 +75,14 @@
private String permissions;
private AppActivities activities;
+
+ @JsonIgnore
+ private String folderName;
// -------------------------------------------------------------------------
// Logic
// -------------------------------------------------------------------------
+
public String getVersion()
{
return version;
@@ -188,29 +192,48 @@
{
this.activities = activities;
}
-
- // -------------------------------------------------------------------------
- // Hashcode & Equals
- // -------------------------------------------------------------------------
+
+ public String getFolderName()
+ {
+ return folderName;
+ }
+
+ public void setFolderName( String folderName )
+ {
+ this.folderName = folderName;
+ }
+
+ // -------------------------------------------------------------------------
+ // Hashcode & Equals
+ // -------------------------------------------------------------------------
+
@Override
- public int hashCode() {
+ public int hashCode()
+ {
int hash = 7;
hash = 79 * hash + (this.name != null ? this.name.hashCode() : 0);
return hash;
}
@Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
+ public boolean equals( Object obj )
+ {
+ if ( obj == null )
+ {
+ return false;
+ }
+ if ( getClass() != obj.getClass() )
+ {
+ return false;
+ }
+
final App other = (App) obj;
- if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
+
+ if ( (this.name == null) ? (other.name != null) : !this.name.equals( other.name ) )
+ {
return false;
}
+
return true;
}
}
=== 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-09-26 16:34:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppManagerService.java 2013-09-26 16:53:50 +0000
@@ -90,13 +90,6 @@
boolean deleteApp( String name );
/**
- * Returns the name of the specfic app folder
- * @param app
- * @return folder name of where app is installed
- */
- String getAppFolderName( App app );
-
- /**
* Saves the folder in which apps will be expanded
* @param appFolderPath
*/
=== 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 16:34:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/appmanager/DefaultAppManagerService.java 2013-09-26 16:53:50 +0000
@@ -28,13 +28,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -48,6 +45,9 @@
import org.hisp.dhis.setting.SystemSettingManager;
import org.springframework.beans.factory.annotation.Autowired;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
/**
* @author Saptarshi Purkayastha
*/
@@ -56,8 +56,6 @@
{
private static final Log log = LogFactory.getLog( DefaultDataValueService.class );
- private HashMap<App, String> appFolderNames;
-
@Autowired
private SystemSettingManager appSettingManager;
@@ -76,7 +74,6 @@
@Override
public List<App> getInstalledApps()
{
- this.appFolderNames = new HashMap<App, String>();
List<App> appList = new ArrayList<App>();
ObjectMapper mapper = new ObjectMapper();
mapper.configure( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false );
@@ -97,8 +94,8 @@
try
{
App app = mapper.readValue( appManifest, App.class );
+ app.setFolderName( folder.getName() );
appList.add( app );
- appFolderNames.put( app, folder.getName() );
}
catch ( IOException ex )
{
@@ -128,8 +125,7 @@
if ( getInstalledApps().contains( app ) )
{
- String folderPath = getAppFolderPath() + File.separator
- + getAppFolderName( app );
+ String folderPath = getAppFolderPath() + File.separator + app.getFolderName();
FileUtils.forceDelete( new File( folderPath ) );
}
@@ -161,7 +157,7 @@
{
try
{
- String folderPath = getAppFolderPath() + File.separator + getAppFolderName( app );
+ String folderPath = getAppFolderPath() + File.separator + app.getFolderName();
FileUtils.forceDelete( new File( folderPath ) );
return true;
}
@@ -205,17 +201,6 @@
}
@Override
- public String getAppFolderName( App app )
- {
- if ( null == appFolderNames )
- {
- getInstalledApps();
- }
-
- return appFolderNames.get( app );
- }
-
- @Override
public String getAppBaseUrl()
{
return StringUtils.trimToNull( (String) appSettingManager.getSystemSetting( KEY_APP_BASE_URL ) );
=== 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-09-26 15:20:53 +0000
+++ dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AppListAction.java 2013-09-26 16:53:50 +0000
@@ -61,13 +61,6 @@
return appList;
}
- private List<String> appFolderNames = new ArrayList<String>();
-
- public List<String> getAppFolderNames()
- {
- return appFolderNames;
- }
-
//TODO create settings to set for external server like Apache2/nginx
//TODO Should be a per-app setting
@@ -90,11 +83,6 @@
appsRootUrl = appManagerService.getAppBaseUrl();
- for ( App app : getAppList() )
- {
- appFolderNames.add( appManagerService.getAppFolderName( app ) );
- }
-
return SUCCESS;
}
}
=== 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-08-16 12:29:21 +0000
+++ dhis-2/dhis-web/dhis-web-appmanager/src/main/webapp/dhis-web-appmanager/index.vm 2013-09-26 16:53:50 +0000
@@ -5,9 +5,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='$appsRootUrl/$appFolderNames.get($foreach.index)/$app.launchPath'">
+ <li class="introItem" onclick="window.location.href='$appsRootUrl/${app.folderName}/${app.launchPath}'">
<span class="introItemHeader">
- <img style="float:left; margin-right:15px" src="$appsRootUrl/$appFolderNames.get($foreach.index)/$app.icons.icon48">
+ <img style="float:left; margin-right:15px" src="$appsRootUrl/${app.folderName}/${app.icons.icon48}">
${app.name}
</span><br>
$i18n.getString( "appmanager_author" ): ${app.developer.name}<br>