dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #22712
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11004: Updating appManifest to detect currently installed Dhis instance
------------------------------------------------------------
revno: 11004
committer: Saptarshi <sunbiz@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2013-05-26 17:07:15 +0200
message:
Updating appManifest to detect currently installed Dhis instance
added:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppDhis.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppActivities.java
dhis-2/dhis-api/src/test/java/org/hisp/dhis/appmanager/AppTest.java
dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AddAppAction.java
dhis-2/dhis-web/dhis-web-appmanager/src/main/resources/org/hisp/dhis/appmanager/i18n_module.properties
dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties
dhis-2/dhis-web/dhis-web-portal/pom.xml
--
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/AppActivities.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppActivities.java 2013-05-17 11:14:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppActivities.java 2013-05-26 15:07:15 +0000
@@ -1,7 +1,5 @@
package org.hisp.dhis.appmanager;
-import java.io.Serializable;
-
/*
* Copyright (c) 2004-2013, University of Oslo
* All rights reserved.
@@ -29,6 +27,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.io.Serializable;
+
/**
* @author Saptarshi
*/
@@ -39,18 +40,15 @@
* Determines if a de-serialized file is compatible with this class.
*/
private static final long serialVersionUID = 7530768303537807631L;
-
- // TODO: allow get
- private String dhisUrl;
-
- public String getDhisUrl()
- {
- return dhisUrl;
- }
-
- public void setDhisUrl( String dhisUrl )
- {
- this.dhisUrl = dhisUrl;
- }
-
+
+ @JsonProperty("dhis")
+ private AppDhis dhis;
+
+ public AppDhis getDhis() {
+ return dhis;
+ }
+
+ public void setDhis(AppDhis dhis) {
+ this.dhis = dhis;
+ }
}
\ No newline at end of file
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppDhis.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppDhis.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppDhis.java 2013-05-26 15:07:15 +0000
@@ -0,0 +1,55 @@
+package org.hisp.dhis.appmanager;
+
+/*
+ * Copyright (c) 2004-2013, 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 com.fasterxml.jackson.annotation.JsonProperty;
+import java.io.Serializable;
+
+/**
+ * @author Saptarshi
+ */
+public class AppDhis
+ implements Serializable
+{
+ /**
+ * Determines if a de-serialized file is compatible with this class.
+ */
+ private static final long serialVersionUID = -8854371580010728182L;
+
+ @JsonProperty("href")
+ private String href;
+
+ public String getHref()
+ {
+ return href;
+ }
+
+ public void setHref(String href) {
+ this.href = href;
+ }
+}
\ No newline at end of file
=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/appmanager/AppTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/appmanager/AppTest.java 2013-05-17 11:14:26 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/appmanager/AppTest.java 2013-05-26 15:07:15 +0000
@@ -51,7 +51,6 @@
{
String appJson = FileUtils.readFileToString( new File( this.getClass().getResource( "/manifest.webapp" )
.getFile() ) );
- //System.out.println( "APPJSON = " + appJson );
ObjectMapper mapper = new ObjectMapper();
mapper.configure( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false );
this.app = mapper.readValue( appJson, App.class );
@@ -96,4 +95,14 @@
Assert.assertNull( app.getDeveloper().getEmail() );
Assert.assertNull( app.getDeveloper().getCompany() );
}
+
+ @Test
+ public void testActivities()
+ {
+ AppDhis dhisActivity = app.getActivities().getDhis();
+ Assert.assertEquals( dhisActivity.getHref(), "http://localhost:8080/dhis" );
+ dhisActivity.setHref("ALL TEST");
+ Assert.assertEquals( dhisActivity.getHref(), "ALL TEST" );
+ }
+
}
=== modified file 'dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AddAppAction.java'
--- dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AddAppAction.java 2013-05-25 16:25:22 +0000
+++ dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AddAppAction.java 2013-05-26 15:07:15 +0000
@@ -34,8 +34,10 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
+import javax.servlet.http.HttpServletRequest;
import org.apache.ant.compress.taskdefs.Unzip;
import org.apache.commons.io.FileUtils;
+import org.apache.struts2.ServletActionContext;
import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipFile;
import org.hisp.dhis.appmanager.App;
@@ -43,6 +45,7 @@
import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.security.authority.SystemAuthoritiesProvider;
import org.hisp.dhis.system.util.StreamUtils;
+import org.hisp.dhis.util.ContextUtils;
import org.springframework.beans.factory.annotation.Autowired;
/**
@@ -126,7 +129,7 @@
ObjectMapper mapper = new ObjectMapper();
mapper.configure( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false );
App app = mapper.readValue( appManifest, App.class );
-
+
// Delete if app is already installed
if ( appManagerService.getInstalledApps().contains( app ) )
{
@@ -141,14 +144,32 @@
unzip.setSrc( file );
unzip.setDest( new File( dest ) );
unzip.execute();
+
+ //Updating Dhis Server Location
+ File updateManifest = new File(dest + File.separator + "manifest.webapp");
+ App installedApp = mapper.readValue(updateManifest, App.class);
+
+ if(installedApp.getActivities().getDhis().getHref().equals("*"))
+ {
+ //TODO: Check why ContextUtils.getContextPath is not working
+ //String rootPath = ContextUtils.getContextPath(ServletActionContext.getRequest());
+ HttpServletRequest req = ServletActionContext.getRequest();
+ StringBuffer fullUrl = req.getRequestURL();
+ String baseUrl = ContextUtils.getBaseUrl(req);
+ String rootPath = fullUrl.substring(0,fullUrl.indexOf("/", baseUrl.length()));
+
+ installedApp.getActivities().getDhis().setHref(rootPath);
+ mapper.writeValue(updateManifest, installedApp);
+ }
+ zip.close();
message = i18n.getString( "appmanager_install_success" );
}
else
{
+ zip.close();
message = i18n.getString( "appmanager_invalid_package" );
return "failure";
}
- zip.close();
}
else
{
=== modified file 'dhis-2/dhis-web/dhis-web-appmanager/src/main/resources/org/hisp/dhis/appmanager/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-appmanager/src/main/resources/org/hisp/dhis/appmanager/i18n_module.properties 2013-05-25 16:25:22 +0000
+++ dhis-2/dhis-web/dhis-web-appmanager/src/main/resources/org/hisp/dhis/appmanager/i18n_module.properties 2013-05-26 15:07:15 +0000
@@ -1,4 +1,4 @@
-dhis-web-appmanager=Manage Apps
+dhis-web-appmanager=Apps
appmanager_list_app=Installed Apps
appmanager_settings=Settings
appmanager_go=Get New Apps
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties 2013-04-17 13:38:45 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties 2013-05-26 15:07:15 +0000
@@ -66,6 +66,7 @@
dhis-web-sms=SMS
dhis-web-maintenance-in=Configuration
dhis-web-linelisting-mp=Manpower
+dhis-web-appmanager=Apps
#-- Intro modules -------------------------------------------------------------#
=== modified file 'dhis-2/dhis-web/dhis-web-portal/pom.xml'
--- dhis-2/dhis-web/dhis-web-portal/pom.xml 2013-03-22 13:47:40 +0000
+++ dhis-2/dhis-web/dhis-web-portal/pom.xml 2013-05-26 15:07:15 +0000
@@ -176,6 +176,12 @@
<version>${project.version}</version>
<type>war</type>
</dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-web-appmanager</artifactId>
+ <version>${project.version}</version>
+ <type>war</type>
+ </dependency>
</dependencies>
<properties>
<rootDir>../../</rootDir>