=== added directory 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager' === added 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 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/App.java 2013-05-17 11:14:26 +0000 @@ -0,0 +1,191 @@ +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.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; + +/** + * @author Saptarshi + */ +public class App + implements Serializable +{ + + /** + * Determines if a de-serialized file is compatible with this class. + */ + private static final long serialVersionUID = -6638197841892194228L; + + /** + * Required. + */ + private String version; + + private String name; + + @JsonProperty( "launch_path" ) + private String launchPath; + + @JsonProperty( "installs_allowed_from" ) + private String[] installsAllowedFrom; + + @JsonProperty( "default_locale" ) + private String defaultLocale; + + /** + * Optional. + */ + private String description; + + private AppIcons icons; + + private AppDeveloper developer; + + @JsonIgnore + private String locales; + + @JsonIgnore + private String permissions; + + private AppActivities activities; + + // ------------------------------------------------------------------------- + // Logic + // ------------------------------------------------------------------------- + public String getVersion() + { + return version; + } + + public void setVersion( String version ) + { + this.version = version; + } + + public String getName() + { + return name; + } + + public void setName( String name ) + { + this.name = name; + } + + public String getLaunchPath() + { + return launchPath; + } + + public void setLaunchPath( String launchPath ) + { + this.launchPath = launchPath; + } + + public String[] getInstallsAllowedFrom() + { + return installsAllowedFrom; + } + + public void setInstallsAllowedFrom( String[] installsAllowedFrom ) + { + this.installsAllowedFrom = installsAllowedFrom; + } + + public String getDefaultLocale() + { + return defaultLocale; + } + + public void setDefaultLocale( String defaultLocale ) + { + this.defaultLocale = defaultLocale; + } + + public String getDescription() + { + return description; + } + + public void setDescription( String description ) + { + this.description = description; + } + + public AppDeveloper getDeveloper() + { + return developer; + } + + public void setDeveloper( AppDeveloper developer ) + { + this.developer = developer; + } + + public AppIcons getIcons() + { + return icons; + } + + public void setIcons( AppIcons icons ) + { + this.icons = icons; + } + + public String getLocales() + { + return locales; + } + + public void setLocales( String locales ) + { + this.locales = locales; + } + + public String getPermissions() + { + return permissions; + } + + public void setPermissions( String permissions ) + { + this.permissions = permissions; + } + + public AppActivities getActivities() + { + return activities; + } + + public void setActivities( AppActivities activities ) + { + this.activities = activities; + } + +} === added 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 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppActivities.java 2013-05-17 11:14:26 +0000 @@ -0,0 +1,56 @@ +package org.hisp.dhis.appmanager; + +import java.io.Serializable; + +/* + * 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. + */ + +/** + * @author Saptarshi + */ +public class AppActivities + implements Serializable +{ + /** + * 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; + } + +} \ No newline at end of file === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppDeveloper.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppDeveloper.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppDeveloper.java 2013-05-17 11:14:26 +0000 @@ -0,0 +1,99 @@ +package org.hisp.dhis.appmanager; + +/* + * Copyright (c) 2004-2011, 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 java.io.Serializable; + +/** + * @author Saptarshi + */ +public class AppDeveloper + implements Serializable +{ + + /** + * Determines if a de-serialized file is compatible with this class. + */ + private static final long serialVersionUID = -8865601558938806456L; + + /** + * Required. + */ + private String url; + + /** + * Optional. + */ + private String name; + + private String company; + + private String email; + + // ------------------------------------------------------------------------- + // Logic + // ------------------------------------------------------------------------- + public String getUrl() + { + return url; + } + + public void setUrl( String url ) + { + this.url = url; + } + + public String getName() + { + return name; + } + + public void setName( String name ) + { + this.name = name; + } + + public String getCompany() + { + return company; + } + + public void setCompany( String company ) + { + this.company = company; + } + + public String getEmail() + { + return email; + } + + public void setEmail( String email ) + { + this.email = email; + } +} === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppIcons.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppIcons.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppIcons.java 2013-05-17 11:14:26 +0000 @@ -0,0 +1,86 @@ +package org.hisp.dhis.appmanager; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; + +/* + * 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. + */ + +/** + * @author Saptarshi + */ +public class AppIcons + implements Serializable +{ + /** + * Determines if a de-serialized file is compatible with this class. + */ + private static final long serialVersionUID = 5041924160867190242L; + + /** + * Optional. + */ + @JsonProperty( "16" ) + private String icon16; + + @JsonProperty( "48" ) + private String icon48; + + @JsonProperty( "128" ) + private String icon128; + + public String getIcon16() + { + return icon16; + } + + public void setIcon16( String icon16 ) + { + this.icon16 = icon16; + } + + public String getIcon48() + { + return icon48; + } + + public void setIcon48( String icon48 ) + { + this.icon48 = icon48; + } + + public String getIcon128() + { + return icon128; + } + + public void setIcon128( String icon128 ) + { + this.icon128 = icon128; + } + +} \ No newline at end of file === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppStoreService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppStoreService.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppStoreService.java 2013-05-17 11:14:26 +0000 @@ -0,0 +1,80 @@ +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 java.util.List; + +/** + * @author Saptarshi Purkayastha + * @version $Id$ + */ +public interface AppStoreService +{ + + String ID = AppStoreService.class.getName(); + + final String KEY_APP_FOLDER_PATH = "appFolderPath"; + + final String KEY_APP_STORE_URL = "appStoreUrl"; + + /** + * Returns the full path to the folder where apps are extracted + * @return app folder path + */ + String getAppFolderPath(); + + /** + * Returns the url of the app repository + * @return url of appstore + */ + String getAppStoreUrl(); + + /** + * Returns a list of all the installed apps at @see getAppFolderPath + * @return list of installed apps + */ + List getInstalledApps(); + + /** + * 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 + */ + void setAppFolderPath( String appFolderPath ); + + /** + * Saves the URL of the apps repository + */ + void setAppStoreUrl( String appStoreUrl ); + +} === added directory 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/appmanager' === added 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 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/appmanager/AppTest.java 2013-05-17 11:14:26 +0000 @@ -0,0 +1,99 @@ +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.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.File; +import java.io.IOException; +import org.apache.commons.io.FileUtils; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * @author Saptarshi + * @version $Id$ + */ +public class AppTest +{ + + private App app; + + @Before + public void setUp() + throws IOException + { + 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 ); + } + + @After + public void tearDown() + { + } + + // TODO: Verify missing property + @Test + public void testRequiredProperties() + { + Assert.assertEquals( app.getVersion(), "0.1" ); + Assert.assertEquals( app.getName(), "Test App" ); + Assert.assertEquals( app.getLaunchPath(), "/index.html" ); + Assert.assertEquals( app.getInstallsAllowedFrom()[0], "*" ); + Assert.assertEquals( app.getDefaultLocale(), "en" ); + } + + // TODO: Complete test for skipped optional properties + @Test + public void testOptionalProperties() + { + Assert.assertEquals( app.getDescription(), "Test Description" ); + } + + @Test + public void testIcons() + { + Assert.assertEquals( app.getIcons().getIcon16(), "/img/icons/mortar-16.png" ); + Assert.assertEquals( app.getIcons().getIcon48(), "/img/icons/mortar-48.png" ); + Assert.assertEquals( app.getIcons().getIcon128(), "/img/icons/mortar-128.png" ); + } + + @Test + public void testDeveloper() + { + Assert.assertEquals( app.getDeveloper().getName(), "Test Developer" ); + Assert.assertEquals( app.getDeveloper().getUrl(), "http://test" ); + Assert.assertNull( app.getDeveloper().getEmail() ); + Assert.assertNull( app.getDeveloper().getCompany() ); + } +} === added file 'dhis-2/dhis-api/src/test/resources/manifest.webapp' --- dhis-2/dhis-api/src/test/resources/manifest.webapp 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/test/resources/manifest.webapp 2013-05-17 11:14:26 +0000 @@ -0,0 +1,39 @@ +{ + "version": "0.1", + "name": "Test App", + "description": "Test Description", + "launch_path": "/index.html", + "icons": { + "16": "/img/icons/mortar-16.png", + "48": "/img/icons/mortar-48.png", + "128": "/img/icons/mortar-128.png" + }, + "developer": { + "name": "Test Developer", + "url": "http://test" + }, + "installs_allowed_from": ["*","127.0.0.1"], + "locales": { + "es": { + "description": "Test", + "developer": { + "url": "http://test" + } + }, + "it": { + "description": "Test", + "developer": { + "url": "http://test" + } + } + }, + "default_locale": "en", + "permissions": { + "systemXHR": {} + }, + "activities": { + "dhis": { + "href": "http://localhost:8080/dhis" + } + } +} \ No newline at end of file