=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfiguration.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfiguration.java 2012-03-01 08:56:47 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfiguration.java 2012-03-21 02:20:05 +0000 @@ -28,11 +28,9 @@ */ import java.io.Serializable; +import java.util.ArrayList; import java.util.List; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlElements; import javax.xml.bind.annotation.XmlRootElement; /** @@ -46,19 +44,21 @@ private String longNumber; - private List gateways; - private Integer pollingInterval; private boolean enabled = false; + private List gateways; + public SmsConfiguration() { + this.gateways = new ArrayList(); } public SmsConfiguration( boolean enabled ) { this.enabled = enabled; + this.gateways = new ArrayList(); } public boolean isEnabled() @@ -81,11 +81,13 @@ this.longNumber = longNumber; } - @XmlElementWrapper( name = "gateways" ) - @XmlElements( { @XmlElement( name = "bulksms", type = BulkSmsGatewayConfig.class ), - @XmlElement( name = "clickatell", type = ClickatellGatewayConfig.class ), - @XmlElement( name = "http", type = GenericHttpGatewayConfig.class ), - @XmlElement( name = "modem", type = ModemGatewayConfig.class ) } ) + /* + * @XmlElementWrapper( name = "gateways" ) @XmlElements( { @XmlElement( name = + * "bulksms", type = BulkSmsGatewayConfig.class ), @XmlElement( name = + * "clickatell", type = ClickatellGatewayConfig.class ), @XmlElement( name = + * "http", type = GenericHttpGatewayConfig.class ), @XmlElement( name = + * "modem", type = ModemGatewayConfig.class ) } ) + */ public List getGateways() { return gateways; === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsTransportService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsTransportService.java 2012-03-14 10:36:55 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsTransportService.java 2012-03-21 02:20:05 +0000 @@ -37,4 +37,6 @@ extends OutboundSmsService { Map getGatewayMap(); + + String stopService(); } === modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/SmsConfigurationManagerImpl.java' --- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/SmsConfigurationManagerImpl.java 2012-03-20 11:07:14 +0000 +++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/SmsConfigurationManagerImpl.java 2012-03-21 02:20:05 +0000 @@ -83,7 +83,7 @@ { // TODO: Need to make these problems available in GUI! log.warn( "Unable to initialize service " + smsConfigurable.getClass().getSimpleName() - + "with configuration " + smsConfiguration, t ); + + " with configuration " + smsConfiguration, t ); } } } === modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java' --- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java 2012-03-14 10:36:55 +0000 +++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java 2012-03-21 02:20:05 +0000 @@ -65,9 +65,9 @@ private final String CLICKATELL_GATEWAY = "clickatell_gw"; - private final String HTTP_GATEWAY = "generic_http_gw"; + private final String HTTP_GATEWAY = "http_gw"; - private final String MODEM_GATEWAY = "modem_gateway"; + private final String MODEM_GATEWAY = "modem_gw"; // ------------------------------------------------------------------------- // Implementation methods @@ -80,6 +80,17 @@ } @Override + public Map getGatewayMap() + { + if ( gatewayMap == null || gatewayMap.isEmpty() ) + { + reloadConfig(); + } + + return gatewayMap; + } + + @Override public void sendMessage( OutboundSms sms, String gatewayId ) throws SmsServiceException { @@ -179,19 +190,21 @@ log.debug( "Loading configuration" ); - reloadConfig(); - - if ( config.isEnabled() ) + if ( config.isEnabled() && reloadConfig() ) { log.debug( "Starting SmsLib" ); startService(); } else { - log.debug( "Sms not enabled, won't start service" ); + log.debug( "Sms not enabled or there is no any gateway, won't start service" ); } } + // ------------------------------------------------------------------------- + // Supportive methods + // ------------------------------------------------------------------------- + private String createTmpGroup( Set recipients ) { String groupName = Thread.currentThread().getName(); @@ -234,27 +247,38 @@ } } - private void stopService() + @Override + public String stopService() { + String status = "success"; + try { getService().stopService(); } catch ( SMSLibException e ) { + status = "Unable to stop smsLib service" + e.getCause().getMessage(); + log.warn( "Unable to stop smsLib service", e ); throw new SmsServiceException( "Unable to stop smsLib service", e ); } catch ( IOException e ) { + status = "Unable to stop smsLib service" + e.getCause().getMessage(); + log.warn( "Unable to stop smsLib service", e ); throw new SmsServiceException( "Unable to stop smsLib service", e ); } catch ( InterruptedException e ) { + status = "Unable to stop smsLib service" + e.getCause().getMessage(); + log.warn( "Unable to stop smsLib service", e ); throw new SmsServiceException( "Unable to stop smsLib service", e ); } + + return status; } private Service getService() @@ -262,7 +286,7 @@ return Service.getInstance(); } - private void reloadConfig() + private boolean reloadConfig() throws SmsServiceException { Service service = Service.getInstance(); @@ -273,6 +297,8 @@ AGateway gateway = null; + boolean reloaded = false; + // Add gateways for ( SmsGatewayConfig gatewayConfig : config.getGateways() ) { @@ -299,14 +325,20 @@ gatewayMap.put( MODEM_GATEWAY, gateway.getGatewayId() ); } + reloaded = true; + log.debug( "Added gateway " + gatewayConfig.getName() ); } catch ( GatewayException e ) { + reloaded = false; + log.warn( "Unable to load gateway " + gatewayConfig.getName(), e ); throw new SmsServiceException( "Unable to load gateway" + gatewayConfig.getName(), e ); } } + + return reloaded; } private class OutboundNotification @@ -318,16 +350,4 @@ log.debug( "Sent message through gateway " + gateway.getGatewayId() + ": " + msg ); } } - - @Override - public Map getGatewayMap() - { - if ( gatewayMap == null || gatewayMap.isEmpty() ) - { - reloadConfig(); - } - - return gatewayMap; - } - } === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js 2012-03-07 10:32:33 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js 2012-03-21 02:20:05 +0000 @@ -457,5 +457,13 @@ "smtpPassword" : { "required" : true } + }, + "SMSConfig" : { + "pollingInterval" : { + "digits" : true + }, + "serverPhoneNumber" : { + "digits" : true + } } }; === removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/GetMobileConfigurationAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/GetMobileConfigurationAction.java 2012-03-14 10:36:55 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/GetMobileConfigurationAction.java 1970-01-01 00:00:00 +0000 @@ -1,78 +0,0 @@ -package org.hisp.dhis.mobile.action; - -/* - * Copyright (c) 2004-2012, 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 org.hisp.dhis.sms.SmsConfigurationManager; -import org.hisp.dhis.sms.config.SmsConfiguration; -import org.springframework.beans.factory.annotation.Autowired; - -import com.opensymphony.xwork2.Action; - -/** - * @author - * @version $Id$ - */ - -public class GetMobileConfigurationAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - @Autowired - private SmsConfigurationManager smsConfigurationManager; - - // ------------------------------------------------------------------------- - // Output - // ------------------------------------------------------------------------- - - private SmsConfiguration smsConfig; - - public SmsConfiguration getSmsConfig() - { - return smsConfig; - } - - public boolean getSmsServiceStatus() - { - return this.smsConfig != null && this.smsConfig.isEnabled(); - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - public String execute() - throws Exception - { - smsConfig = smsConfigurationManager.getSmsConfiguration(); - - return SUCCESS; - } -} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/GetSmsConfigurationAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/GetSmsConfigurationAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/GetSmsConfigurationAction.java 2012-03-21 02:20:05 +0000 @@ -0,0 +1,128 @@ +package org.hisp.dhis.mobile.action; + +/* + * Copyright (c) 2004-2012, 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.HashMap; +import java.util.Map; + +import org.hisp.dhis.sms.SmsConfigurationManager; +import org.hisp.dhis.sms.config.BulkSmsGatewayConfig; +import org.hisp.dhis.sms.config.ClickatellGatewayConfig; +import org.hisp.dhis.sms.config.ModemGatewayConfig; +import org.hisp.dhis.sms.config.SmsConfiguration; +import org.hisp.dhis.sms.config.SmsGatewayConfig; +import org.springframework.beans.factory.annotation.Autowired; + +import com.opensymphony.xwork2.Action; + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ + +public class GetSmsConfigurationAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + @Autowired + private SmsConfigurationManager smsConfigurationManager; + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private Map gatewayConfigMap1 = new HashMap(); + + public Map getGatewayConfigMap1() + { + return gatewayConfigMap1; + } + + private Map gatewayConfigMap2 = new HashMap(); + + public Map getGatewayConfigMap2() + { + return gatewayConfigMap2; + } + + private SmsConfiguration smsConfig; + + public SmsConfiguration getSmsConfig() + { + return smsConfig; + } + + public boolean getSmsServiceStatus() + { + return this.smsConfig != null && this.smsConfig.isEnabled(); + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + smsConfig = smsConfigurationManager.getSmsConfiguration(); + + if ( smsConfig != null ) + { + int index = 0; + + for ( SmsGatewayConfig gw : smsConfig.getGateways() ) + { + index = smsConfig.getGateways().indexOf( gw ); + + gatewayConfigMap1.put( index, gw ); + + if ( gw instanceof BulkSmsGatewayConfig ) + { + gatewayConfigMap2.put( 0, index ); + } + else if ( gw instanceof ClickatellGatewayConfig ) + { + gatewayConfigMap2.put( 1, index ); + } + else if ( gw instanceof ModemGatewayConfig ) + { + gatewayConfigMap2.put( 2, index ); + } + else + { + gatewayConfigMap2.put( 3, index ); + } + } + } + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/RemoveGatewayConfigAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/RemoveGatewayConfigAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/RemoveGatewayConfigAction.java 2012-03-21 02:20:05 +0000 @@ -0,0 +1,90 @@ +package org.hisp.dhis.mobile.action; + +/* + * Copyright (c) 2004-2012, 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.Iterator; + +import org.hisp.dhis.sms.SmsConfigurationManager; +import org.hisp.dhis.sms.config.SmsConfiguration; +import org.hisp.dhis.sms.config.SmsGatewayConfig; +import org.springframework.beans.factory.annotation.Autowired; + +import com.opensymphony.xwork2.Action; + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ + +public class RemoveGatewayConfigAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + @Autowired + private SmsConfigurationManager smsConfigurationManager; + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + SmsConfiguration smsConfig = smsConfigurationManager.getSmsConfiguration(); + + Iterator it = smsConfig.getGateways().iterator(); + + while( it.hasNext() ) + { + if ( smsConfig.getGateways().indexOf( it.next() ) == id ) + { + it.remove(); + + smsConfigurationManager.updateSmsConfiguration( smsConfig ); + + break; + } + } + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/SaveSmsConfigurationAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/SaveSmsConfigurationAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/SaveSmsConfigurationAction.java 2012-03-21 02:20:05 +0000 @@ -0,0 +1,90 @@ +package org.hisp.dhis.mobile.action; + +/* + * Copyright (c) 2004-2012, 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 org.hisp.dhis.sms.SmsConfigurationManager; +import org.hisp.dhis.sms.config.SmsConfiguration; +import org.springframework.beans.factory.annotation.Autowired; + +import com.opensymphony.xwork2.Action; + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ + +public class SaveSmsConfigurationAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + @Autowired + private SmsConfigurationManager smsConfigurationManager; + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private Integer pollingInterval; + + public void setPollingInterval( Integer pollingInterval ) + { + this.pollingInterval = pollingInterval; + } + + private String serverPhoneNumber; + + public void setServerPhoneNumber( String longNumber ) + { + this.serverPhoneNumber = longNumber; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + SmsConfiguration smsConfig = smsConfigurationManager.getSmsConfiguration(); + + if ( smsConfig == null ) + { + smsConfig = new SmsConfiguration( true ); + } + + smsConfig.setPollingInterval( pollingInterval ); + smsConfig.setLongNumber( serverPhoneNumber ); + + smsConfigurationManager.updateSmsConfiguration( smsConfig ); + + return SUCCESS; + } +} === removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowUpdateGateWayConfigFormAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowUpdateGateWayConfigFormAction.java 2012-03-20 11:07:14 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowUpdateGateWayConfigFormAction.java 1970-01-01 00:00:00 +0000 @@ -1,103 +0,0 @@ -package org.hisp.dhis.mobile.action; - -/* - * Copyright (c) 2004-2012, 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.HashMap; -import java.util.Map; - -import org.hisp.dhis.sms.SmsConfigurationManager; -import org.hisp.dhis.sms.config.BulkSmsGatewayConfig; -import org.hisp.dhis.sms.config.ClickatellGatewayConfig; -import org.hisp.dhis.sms.config.ModemGatewayConfig; -import org.hisp.dhis.sms.config.SmsConfiguration; -import org.hisp.dhis.sms.config.SmsGatewayConfig; -import org.springframework.beans.factory.annotation.Autowired; - -import com.opensymphony.xwork2.Action; - -/** - * @author Dang Duy Hieu - * @version $Id$ - */ - -public class ShowUpdateGateWayConfigFormAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - @Autowired - private SmsConfigurationManager smsConfigurationManager; - - // ------------------------------------------------------------------------- - // Output - // ------------------------------------------------------------------------- - - private Map gatewayConfigMap = new HashMap(); - - public Map getGatewayConfigMap() - { - return gatewayConfigMap; - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - public String execute() - throws Exception - { - SmsConfiguration smsConfig = smsConfigurationManager.getSmsConfiguration(); - - if ( smsConfig != null ) - { - for ( SmsGatewayConfig gw : smsConfig.getGateways() ) - { - if ( gw instanceof BulkSmsGatewayConfig ) - { - gatewayConfigMap.put( 0, gw ); - } - else if ( gw instanceof ClickatellGatewayConfig ) - { - gatewayConfigMap.put( 1, gw ); - } - else if ( gw instanceof ModemGatewayConfig ) - { - gatewayConfigMap.put( 2, gw ); - } - else - { - gatewayConfigMap.put( 3, gw ); - } - } - } - - return SUCCESS; - } -} === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateBulkGateWayConfigAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateBulkGateWayConfigAction.java 2012-03-20 11:07:14 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateBulkGateWayConfigAction.java 2012-03-21 02:20:05 +0000 @@ -1,7 +1,7 @@ package org.hisp.dhis.mobile.action; /* - * Copyright (c) 2004-2011, University of Oslo + * Copyright (c) 2004-2012, University of Oslo * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -49,11 +49,6 @@ @Autowired private SmsConfigurationManager smsConfigurationManager; - public void setSmsConfigurationManager( SmsConfigurationManager smsConfigurationManager ) - { - this.smsConfigurationManager = smsConfigurationManager; - } - // ------------------------------------------------------------------------- // Input // ------------------------------------------------------------------------- @@ -102,7 +97,7 @@ BulkSmsGatewayConfig gatewayConfig = (BulkSmsGatewayConfig) smsConfigurationManager .checkInstanceOfGateway( BulkSmsGatewayConfig.class ); - int index = 0; + int index = -1; if ( gatewayConfig == null ) { === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateClickatellGateWayConfigAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateClickatellGateWayConfigAction.java 2012-03-20 11:07:14 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateClickatellGateWayConfigAction.java 2012-03-21 02:20:05 +0000 @@ -1,7 +1,7 @@ package org.hisp.dhis.mobile.action; /* - * Copyright (c) 2004-2011, University of Oslo + * Copyright (c) 2004-2012, University of Oslo * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -49,11 +49,6 @@ @Autowired private SmsConfigurationManager smsConfigurationManager; - public void setSmsConfigurationManager( SmsConfigurationManager smsConfigurationManager ) - { - this.smsConfigurationManager = smsConfigurationManager; - } - // ------------------------------------------------------------------------- // Input // ------------------------------------------------------------------------- @@ -109,7 +104,7 @@ ClickatellGatewayConfig gatewayConfig = (ClickatellGatewayConfig) smsConfigurationManager .checkInstanceOfGateway( ClickatellGatewayConfig.class ); - int index = 0; + int index = -1; if ( gatewayConfig == null ) { === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateGenericHTTPGateWayConfigAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateGenericHTTPGateWayConfigAction.java 2012-03-20 11:07:14 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateGenericHTTPGateWayConfigAction.java 2012-03-21 02:20:05 +0000 @@ -1,7 +1,7 @@ package org.hisp.dhis.mobile.action; /* - * Copyright (c) 2004-2011, University of Oslo + * Copyright (c) 2004-2012, University of Oslo * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,11 +52,6 @@ @Autowired private SmsConfigurationManager smsConfigurationManager; - public void setSmsConfigurationManager( SmsConfigurationManager smsConfigurationManager ) - { - this.smsConfigurationManager = smsConfigurationManager; - } - // ------------------------------------------------------------------------- // Input // ------------------------------------------------------------------------- @@ -112,7 +107,7 @@ GenericHttpGatewayConfig gatewayConfig = (GenericHttpGatewayConfig) smsConfigurationManager .checkInstanceOfGateway( GenericHttpGatewayConfig.class ); - int index = 0; + int index = -1; if ( gatewayConfig == null ) { === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateModemGateWayConfigAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateModemGateWayConfigAction.java 2012-03-20 11:07:14 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateModemGateWayConfigAction.java 2012-03-21 02:20:05 +0000 @@ -1,7 +1,7 @@ package org.hisp.dhis.mobile.action; /* - * Copyright (c) 2004-2011, University of Oslo + * Copyright (c) 2004-2012, University of Oslo * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -49,11 +49,6 @@ @Autowired private SmsConfigurationManager smsConfigurationManager; - public void setSmsConfigurationManager( SmsConfigurationManager smsConfigurationManager ) - { - this.smsConfigurationManager = smsConfigurationManager; - } - // ------------------------------------------------------------------------- // Input // ------------------------------------------------------------------------- @@ -137,7 +132,7 @@ ModemGatewayConfig gatewayConfig = (ModemGatewayConfig) smsConfigurationManager .checkInstanceOfGateway( ModemGatewayConfig.class ); - int index = 0; + int index = -1; if ( gatewayConfig == null ) { === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml 2012-03-20 11:07:14 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml 2012-03-21 02:20:05 +0000 @@ -6,9 +6,6 @@ - - @@ -46,7 +43,13 @@ + + + + @@ -59,7 +62,7 @@ - + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties 2012-03-20 11:07:14 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties 2012-03-21 02:20:05 +0000 @@ -41,8 +41,10 @@ outbound=Outbound api_id=API ID save_settings=Save Settings +add_update_gw=Add or update gateway show_send_sms_form=Show send SMS form bulk_gw=BulkSMS Gateway clickatell_gw=Clickatell Gateway -generic_http_gw=Generic HTTP Gateway -modem_gw=Modem Gateway \ No newline at end of file +http_gw=Generic HTTP Gateway +modem_gw=Modem Gateway +confirm_delete_gateway=Do you want to delete this gateway configuration ? \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml 2012-03-20 11:07:14 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml 2012-03-21 02:20:05 +0000 @@ -65,18 +65,49 @@ - + /main.vm /dhis-web-maintenance-mobile/smsServiceConfiguration.vm /dhis-web-maintenance-mobile/menu.vm F_MOBILE_SETTINGS - + /main.vm /dhis-web-maintenance-mobile/updateGateway.vm /dhis-web-maintenance-mobile/menu.vm - - + javascript/gateway.js + F_MOBILE_SETTINGS + + + + showSMSConfigureForm.action + + + + ../dhis-web-commons/ajax/jsonResponseSuccess.vm + plainTextError + + + + ../dhis-web-commons/ajax/jsonResponseSuccess.vm + plainTextError + + + + ../dhis-web-commons/ajax/jsonResponseSuccess.vm + plainTextError + + + + ../dhis-web-commons/ajax/jsonResponseSuccess.vm + plainTextError + + + + ../dhis-web-commons/ajax/jsonResponseSuccess.vm + plainTextError + + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/gateway.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/gateway.js 2012-03-20 11:07:14 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/gateway.js 2012-03-21 02:20:05 +0000 @@ -14,7 +14,7 @@ showById( "genericHTTPFields" ); } - currentType = type; + currentType = value; } function hideAll() @@ -69,11 +69,11 @@ { if ( currentType == 'modem' ) { - jQuery.postJSON( "saveBulkSMSConfig.action", { + jQuery.postJSON( "saveModemConfig.action", { gatewayType: getFieldValue( 'gatewayType' ), name: getFieldValue( 'modemFields input[id=name]' ), port: getFieldValue( 'modemFields input[id=port]' ), - baudrate: getFieldValue( 'modemFields input[id=baudrate]' ), + baudRate: getFieldValue( 'modemFields input[id=baudRate]' ), manufacturer: getFieldValue( 'modemFields input[id=manufacturer]' ), model: getFieldValue( 'modemFields input[id=model]' ), pin: getFieldValue( 'modemFields input[id=pin]' ), @@ -96,7 +96,7 @@ } else if ( currentType == 'clickatell' ) { - jQuery.postJSON( "saveBulkSMSConfig.action", { + jQuery.postJSON( "saveClickatellConfig.action", { gatewayType: getFieldValue( 'gatewayType' ), name: getFieldValue( 'clickatellFields input[id=name]' ), username: getFieldValue( 'clickatellFields input[id=username]' ), @@ -108,7 +108,7 @@ } else { - jQuery.postJSON( "saveBulkSMSConfig.action", { + jQuery.postJSON( "saveHTTPConfig.action", { gatewayType: getFieldValue( 'gatewayType' ), name: getFieldValue( 'genericHTTPFields input[id=name]' ), username: getFieldValue( 'genericHTTPFields input[id=username]' ), === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/sendSMSPage.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/sendSMSPage.vm 2012-03-15 10:30:59 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/sendSMSPage.vm 2012-03-21 02:20:05 +0000 @@ -33,10 +33,10 @@ - #set( $keys = $gatewayMap.keySet() ) + #set( $keys = $!gatewayMap.keySet() ) === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smsServiceConfiguration.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smsServiceConfiguration.vm 2012-03-20 11:07:14 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smsServiceConfiguration.vm 2012-03-21 02:20:05 +0000 @@ -9,9 +9,21 @@ } + +

$i18n.getString( "sms_service_configuration" )

-#if( $smsServiceStatus ) -
+ + ## Labels ## Input @@ -50,10 +62,11 @@ - + - + - - #set( $gateWays = $smsConfig.gateways ) - #foreach ($gateWay in $gateWays) - - + + #set( $keys = $!gatewayConfigMap1.keySet() ) + #foreach ($key in $!keys ) + + #set( $gw = $!gatewayConfigMap1.get( $key ) ) + #end @@ -82,6 +96,11 @@
$i18n.getString("server_phone_number"): +
@@ -64,14 +77,15 @@ $i18n.getString( "operation" )
$gateWay.name
$!encoder.htmlEncode( $gw.name ) - + + $i18n.getString( 'remove' )
-#else -

SMS Service is not available

-#end + + \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/updateGateway.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/updateGateway.vm 2012-03-20 11:07:14 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/updateGateway.vm 2012-03-21 02:20:05 +0000 @@ -1,4 +1,3 @@ -

$i18n.getString( "add_update_gateway" )

@@ -31,7 +30,7 @@ $i18n.getString( "gateway_configuration" ) - #set( $modemGateway = $!gatewayConfigMap.get( 2 ) ) + #set( $modemGateway = $!gatewayConfigMap1.get( $gatewayConfigMap2.get( 2 ) ) ) $i18n.getString( "gateway_name" ): @@ -61,9 +60,8 @@ $i18n.getString( "inbound" ): @@ -71,14 +69,13 @@ $i18n.getString( "outbound" ): - #set( $bulkGateway = $!gatewayConfigMap.get( 0 ) ) + #set( $bulkGateway = $!gatewayConfigMap1.get( $gatewayConfigMap2.get( 0 ) ) ) $i18n.getString( "gateway_name" ): @@ -93,7 +90,7 @@ - #set( $clickatellGateway = $!gatewayConfigMap.get( 1 ) ) + #set( $clickatellGateway = $!gatewayConfigMap1.get( $gatewayConfigMap2.get( 1 ) ) ) $i18n.getString( "gateway_name" ): @@ -112,7 +109,7 @@ - #set( $httpGateway = $!gatewayConfigMap.get( 3 ) ) + #set( $httpGateway = $!gatewayConfigMap1.get( $gatewayConfigMap2.get( 3 ) ) ) $i18n.getString( "gateway_name" ): @@ -132,8 +129,8 @@ - - + +