← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5447: Added dhis-service-sms module, with simplistic support for sending smses (WIP)

 

Merge authors:
  Jo Størset (storset)
------------------------------------------------------------
revno: 5447 [merge]
committer: Jo Størset <storset@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-12-15 22:25:44 +0100
message:
  Added dhis-service-sms module, with simplistic support for sending smses (WIP)
removed:
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/BulkSmsGatewayConfig.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/ClickatellGatewayConfig.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/IncomingSms.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/IncomingSmsService.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/IncomingSmsStore.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/ModemGateway.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/OutboundSMS.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/OutboundSmsService.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/OutboundSmsStatus.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/OutboundSmsStore.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/SmsConfig.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/SmsGatewayConfig.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/SmsMessageEncoding.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/SmsMessageStatus.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/SmsService.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/SmsServiceException.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/SmsMessageSender.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/TestOutboundSmsService.java
  dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service/
  dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service/SmsMessageSenderTest.java
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/SmsConfigurationManager.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/SmsServiceException.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/SmsServiceNotEnabledException.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/SmsTransportProviderNotFoundException.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/BulkSmsGatewayConfig.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/ClickatellGatewayConfig.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/ModemGatewayConfig.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfigurable.java
  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/SmsGatewayConfig.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/package-info.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/IncomingSms.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/IncomingSmsService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/IncomingSmsStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/SmsMessageEncoding.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/SmsMessageStatus.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSms.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsStatus.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsTransportService.java
  dhis-2/dhis-services/dhis-service-sms/
  dhis-2/dhis-services/dhis-service-sms/pom.xml
  dhis-2/dhis-services/dhis-service-sms/src/
  dhis-2/dhis-services/dhis-service-sms/src/main/
  dhis-2/dhis-services/dhis-service-sms/src/main/java/
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/
  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/incoming/
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/incoming/HibernateIncomingSmsStore.java
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/HibernateOutboundSmsStore.java
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/SmsMessageSender.java
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/TestOutboundSmsService.java
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/GateWayFactory.java
  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/resources/
  dhis-2/dhis-services/dhis-service-sms/src/main/resources/META-INF/
  dhis-2/dhis-services/dhis-service-sms/src/main/resources/META-INF/dhis/
  dhis-2/dhis-services/dhis-service-sms/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-sms/src/main/resources/org/
  dhis-2/dhis-services/dhis-service-sms/src/main/resources/org/hisp/
  dhis-2/dhis-services/dhis-service-sms/src/main/resources/org/hisp/dhis/
  dhis-2/dhis-services/dhis-service-sms/src/main/resources/org/hisp/dhis/sms/
  dhis-2/dhis-services/dhis-service-sms/src/main/resources/org/hisp/dhis/sms/incoming/
  dhis-2/dhis-services/dhis-service-sms/src/main/resources/org/hisp/dhis/sms/incoming/IncomingSms.hbm.xml
  dhis-2/dhis-services/dhis-service-sms/src/main/resources/org/hisp/dhis/sms/outbound/
  dhis-2/dhis-services/dhis-service-sms/src/main/resources/org/hisp/dhis/sms/outbound/OutboundSms.hbm.xml
  dhis-2/dhis-services/dhis-service-sms/src/test/
  dhis-2/dhis-services/dhis-service-sms/src/test/java/
  dhis-2/dhis-services/dhis-service-sms/src/test/java/org/
  dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/
  dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/
  dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/
  dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/AbstractSmsTest.java
  dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/outbound/
  dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceTest.java
  dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/outbound/OutboundSmsStoreTest.java
  dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/outbound/SmsMessageSenderTest.java
  dhis-2/dhis-services/dhis-service-sms/src/test/resources/
  dhis-2/dhis-services/dhis-service-sms/src/test/resources/test-beans.xml
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SmsConfigurationController.java
  dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/config/
  dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/config/sms.xsl
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/options/SystemSettingManager.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/pom.xml
  dhis-2/dhis-web/dhis-web-api/pom.xml
  dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/pom.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/SendSMSAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowMobileConfigurationFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/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/options/SystemSettingManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/options/SystemSettingManager.java	2011-12-11 15:48:13 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/options/SystemSettingManager.java	2011-12-15 08:46:42 +0000
@@ -79,6 +79,9 @@
     final String AGGREGATION_STRATEGY_BATCH = "batch";
     final String DEFAULT_AGGREGATION_STRATEGY = AGGREGATION_STRATEGY_REAL_TIME;
     final int DEFAULT_COMPLETENESS_OFFSET = 15;
+
+    final String KEY_SMS_CONFIG = "SMS_CONFIG";
+    
     final HashSet<String> DEFAULT_SCHEDULED_PERIOD_TYPES = new HashSet<String>() { {
         add( MonthlyPeriodType.NAME ); 
         add( QuarterlyPeriodType.NAME );

=== added directory 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms'
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/SmsConfigurationManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/SmsConfigurationManager.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/SmsConfigurationManager.java	2011-12-15 08:46:42 +0000
@@ -0,0 +1,12 @@
+package org.hisp.dhis.sms;
+
+import org.hisp.dhis.sms.config.SmsConfiguration;
+
+public interface SmsConfigurationManager
+{
+
+    public SmsConfiguration getSmsConfiguration();
+
+    public void updateSmsConfiguration( SmsConfiguration config );
+
+}
\ No newline at end of file

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/SmsServiceException.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/SmsServiceException.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/SmsServiceException.java	2011-12-15 08:46:42 +0000
@@ -0,0 +1,50 @@
+package org.hisp.dhis.sms;
+
+/*
+ * Copyright (c) 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.
+ */
+
+/**
+ * This exception type is used for signaling any problems during SMS handling.
+ */
+public class SmsServiceException
+    extends RuntimeException
+{
+
+    private static final long serialVersionUID = -7927288362330380301L;
+
+    public SmsServiceException( String message )
+    {
+        super( message );
+    }
+
+    public SmsServiceException( String message, Exception cause )
+    {
+        super( message, cause );
+    }
+
+    
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/SmsServiceNotEnabledException.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/SmsServiceNotEnabledException.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/SmsServiceNotEnabledException.java	2011-12-15 08:46:42 +0000
@@ -0,0 +1,14 @@
+package org.hisp.dhis.sms;
+
+public class SmsServiceNotEnabledException
+    extends SmsServiceException
+{
+
+    private static final long serialVersionUID = -1484667419558937721L;
+
+    public SmsServiceNotEnabledException( )
+    {
+        super( "Sms service is not enabled" );
+    }
+
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/SmsTransportProviderNotFoundException.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/SmsTransportProviderNotFoundException.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/SmsTransportProviderNotFoundException.java	2011-12-15 08:46:42 +0000
@@ -0,0 +1,22 @@
+package org.hisp.dhis.sms;
+
+/**
+ * SmsServiceException signalling no transport provider available to sms service
+ */
+public class SmsTransportProviderNotFoundException
+    extends SmsServiceException
+{
+
+    private static final long serialVersionUID = 8644436214252461786L;
+
+    public SmsTransportProviderNotFoundException( String message, Exception cause )
+    {
+        super( message, cause );
+    }
+
+    public SmsTransportProviderNotFoundException( String message )
+    {
+        super( message );
+    }
+
+}

=== added directory 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config'
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/BulkSmsGatewayConfig.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/BulkSmsGatewayConfig.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/BulkSmsGatewayConfig.java	2011-12-15 11:41:17 +0000
@@ -0,0 +1,72 @@
+package org.hisp.dhis.sms.config;
+
+/*
+ * Copyright (c) 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.
+ */
+
+public class BulkSmsGatewayConfig
+    extends SmsGatewayConfig
+{
+
+    private static final long serialVersionUID = 5249703354480948250L;
+
+    private String username;
+
+    private String password;
+
+    public String getUsername()
+    {
+        return username;
+    }
+
+    public void setUsername( String username )
+    {
+        this.username = username;
+    }
+
+    public String getPassword()
+    {
+        return password;
+    }
+
+    public void setPassword( String password )
+    {
+        this.password = password;
+    }
+
+    @Override
+    public boolean isInbound()
+    {
+        return false;
+    }
+
+    @Override
+    public boolean isOutbound()
+    {
+        return true;
+    }
+
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/ClickatellGatewayConfig.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/ClickatellGatewayConfig.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/ClickatellGatewayConfig.java	2011-12-15 11:41:17 +0000
@@ -0,0 +1,83 @@
+package org.hisp.dhis.sms.config;
+
+
+/*
+ * Copyright (c) 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.
+ */
+
+public class ClickatellGatewayConfig
+    extends SmsGatewayConfig
+{
+
+    private static final long serialVersionUID = -4286107769356591957L;
+
+    private String username;
+    private String password;
+    private String apiId;
+    
+    public String getUsername()
+    {
+        return username;
+    }
+
+    public void setUsername( String username )
+    {
+        this.username = username;
+    }
+
+    public String getPassword()
+    {
+        return password;
+    }
+
+    public void setPassword( String password )
+    {
+        this.password = password;
+    }
+
+    public String getApiId()
+    {
+        return apiId;
+    }
+
+    public void setApiId( String apiId )
+    {
+        this.apiId = apiId;
+    }
+
+    @Override
+    public boolean isInbound()
+    {
+        return false;
+    }
+
+    @Override
+    public boolean isOutbound()
+    {
+        return true;
+    }
+
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/ModemGatewayConfig.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/ModemGatewayConfig.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/ModemGatewayConfig.java	2011-12-15 11:41:17 +0000
@@ -0,0 +1,133 @@
+package org.hisp.dhis.sms.config;
+
+
+/*
+ * Copyright (c) 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.
+ */
+
+public class ModemGatewayConfig
+    extends SmsGatewayConfig
+{
+
+    private static final long serialVersionUID = 5824899163489665038L;
+
+    private String port;
+
+    private int baudRate;
+
+    private String manufacturer;
+
+    private String model;
+
+    private String pin;
+
+    private boolean inbound;
+
+    private boolean outbound;
+
+    private String simMemLocation;
+
+    public String getPort()
+    {
+        return port;
+    }
+
+    public void setPort( String port )
+    {
+        this.port = port;
+    }
+
+    public int getBaudRate()
+    {
+        return baudRate;
+    }
+
+    public void setBaudRate( int baudRate )
+    {
+        this.baudRate = baudRate;
+    }
+
+    public String getManufacturer()
+    {
+        return manufacturer;
+    }
+
+    public void setManufacturer( String manufacturer )
+    {
+        this.manufacturer = manufacturer;
+    }
+
+    public String getModel()
+    {
+        return model;
+    }
+
+    public void setModel( String model )
+    {
+        this.model = model;
+    }
+
+    public String getPin()
+    {
+        return pin;
+    }
+
+    public void setPin( String pin )
+    {
+        this.pin = pin;
+    }
+
+    public boolean isInbound()
+    {
+        return inbound;
+    }
+
+    public void setInbound( boolean inbound )
+    {
+        this.inbound = inbound;
+    }
+
+    public boolean isOutbound()
+    {
+        return outbound;
+    }
+
+    public void setOutbound( boolean outbound )
+    {
+        this.outbound = outbound;
+    }
+
+    public String getSimMemLocation()
+    {
+        return simMemLocation;
+    }
+
+    public void setSimMemLocation( String simMemLocation )
+    {
+        this.simMemLocation = simMemLocation;
+    }
+
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfigurable.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfigurable.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfigurable.java	2011-12-15 08:46:42 +0000
@@ -0,0 +1,24 @@
+package org.hisp.dhis.sms.config;
+
+import org.hisp.dhis.sms.SmsServiceException;
+
+/**
+ * Interface for any service requiring an {@link SmsConfiguration}.
+ */
+public interface SmsConfigurable
+{
+
+    /**
+     * Initialize the service with the provided configuration.
+     * <p>
+     * Services implementing this interface are also expected to be able to
+     * reinitialize based on these setting in a safe way when running.
+     * 
+     * @param smsConfiguration The SMS configuration
+     * @throws SmsServiceException if the service cannot be initialized with the
+     *         provided {@link SmsConfiguration}
+     */
+    public void initialize( SmsConfiguration smsConfiguration )
+        throws SmsServiceException;
+
+}

=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfiguration.java	2011-12-15 11:41:17 +0000
@@ -0,0 +1,109 @@
+package org.hisp.dhis.sms.config;
+
+/*
+ * Copyright (c) 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;
+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;
+
+/**
+ * Serializable configuration object for Sms.
+ */
+@XmlRootElement( name = "smsConfiguration" )
+public class SmsConfiguration implements Serializable
+{
+
+    private static final long serialVersionUID = 7460688383539123303L;
+
+    private String longNumber;
+    
+    private List<SmsGatewayConfig> gateways;
+    
+    private Integer pollingInterval;
+
+    private boolean enabled = false;
+
+    public SmsConfiguration( )
+    {
+    }
+
+    public SmsConfiguration( boolean enabled )
+    {
+        this.enabled = enabled;
+    }
+
+    public boolean isEnabled()
+    {
+        return enabled;
+    }
+
+    public void setEnabled( boolean enabled )
+    {
+        this.enabled = enabled;
+    }
+    
+    public String getLongNumber()
+    {
+        return longNumber;
+    }
+
+    public void setLongNumber( String longNumber )
+    {
+        this.longNumber = longNumber;
+    }
+
+    @XmlElementWrapper(name="gateways")
+    @XmlElements({
+        @XmlElement(name = "bulksms", type = BulkSmsGatewayConfig.class),
+        @XmlElement(name = "clickatell", type = ClickatellGatewayConfig.class),
+        @XmlElement(name = "modem", type = ModemGatewayConfig.class)})
+    public List<SmsGatewayConfig> getGateways()
+    {
+        return gateways;
+    }
+
+    public void setGateways( List<SmsGatewayConfig> gateways )
+    {
+        this.gateways = gateways;
+    }
+
+    public Integer getPollingInterval()
+    {
+        return pollingInterval;
+    }
+
+    public void setPollingInterval( Integer pollingInterval )
+    {
+        this.pollingInterval = pollingInterval;
+    }
+
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsGatewayConfig.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsGatewayConfig.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsGatewayConfig.java	2011-12-15 11:41:17 +0000
@@ -0,0 +1,55 @@
+package org.hisp.dhis.sms.config;
+
+/*
+ * Copyright (c) 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;
+
+/**
+ * Super class for gateway configurations
+ */
+@SuppressWarnings( "serial" )
+public abstract class SmsGatewayConfig implements Serializable
+{
+    
+    private String name;
+
+    public String getName()
+    {
+        return name;
+    }
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+    public abstract boolean isInbound();
+
+    public abstract boolean isOutbound();
+    
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/package-info.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/package-info.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/package-info.java	2011-12-15 08:46:42 +0000
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2004-2010, 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 bobj
+ */
+
+@XmlSchema(
+    namespace = "http://dhis2.org/schema/dxf/2.0";,
+    xmlns = {   
+         @XmlNs(namespaceURI = "http://dhis2.org/schema/dxf/2.0";, prefix = "d")  
+    },
+    elementFormDefault = XmlNsForm.QUALIFIED) 
+
+package org.hisp.dhis.sms.config;
+
+import javax.xml.bind.annotation.XmlSchema;
+import javax.xml.bind.annotation.XmlNs;
+import javax.xml.bind.annotation.XmlNsForm;

=== added directory 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming'
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/IncomingSms.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/IncomingSms.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/IncomingSms.java	2011-12-15 08:46:42 +0000
@@ -0,0 +1,183 @@
+package org.hisp.dhis.sms.incoming;
+
+/*
+ * Copyright (c) 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;
+import java.util.Date;
+
+public class IncomingSms
+    implements Serializable
+{
+
+    private static final long serialVersionUID = 3954710607630454226L;
+
+    private Integer id;
+
+    private SmsMessageEncoding encoding;
+
+    private Date sentDate;
+
+    private Date receivedDate;
+
+    /*
+     * The originator of the received message.
+     */
+    private String originator;
+
+    /*
+     * The ID of the gateway from which the message was received.
+     */
+    private String gatewayId;
+
+    private String text;
+
+    private byte[] bytes;
+
+    private SmsMessageStatus status = SmsMessageStatus.INCOMING;
+
+    private String statusMessage;
+
+    /**
+     * Incoming smses are one of two types, text or binary.
+     * 
+     * @return is this message a text (not binary) message?
+     */
+    public boolean isTextSms()
+    {
+        return text != null;
+    }
+
+    public Integer getId()
+    {
+        return id;
+    }
+
+    public void setId( Integer id )
+    {
+        this.id = id;
+    }
+
+    public SmsMessageEncoding getEncoding()
+    {
+        return encoding;
+    }
+
+    public void setEncoding( SmsMessageEncoding encoding )
+    {
+        this.encoding = encoding;
+    }
+
+    public Date getSentDate()
+    {
+        return sentDate;
+    }
+
+    public void setSentDate( Date sentDate )
+    {
+        this.sentDate = sentDate;
+    }
+
+    public Date getReceivedDate()
+    {
+        return receivedDate;
+    }
+
+    public void setReceivedDate( Date receivedDate )
+    {
+        this.receivedDate = receivedDate;
+    }
+
+    public String getOriginator()
+    {
+        return originator;
+    }
+
+    public void setOriginator( String originator )
+    {
+        this.originator = originator;
+    }
+
+    public String getGatewayId()
+    {
+        return gatewayId;
+    }
+
+    public void setGatewayId( String gatewayId )
+    {
+        this.gatewayId = gatewayId;
+    }
+
+    public String getText()
+    {
+        return text;
+    }
+
+    public void setText( String text )
+    {
+        if ( bytes != null )
+        {
+            throw new IllegalArgumentException("Text and bytes cannot both be set on incoming sms");
+        }
+        this.text = text;
+    }
+
+    public byte[] getBytes()
+    {
+        return bytes;
+    }
+
+    public void setBytes( byte[] bytes )
+    {
+        if ( text != null )
+        {
+            throw new IllegalArgumentException("Text and bytes cannot both be set on incoming sms");
+        }
+        this.bytes = bytes;
+    }
+
+    public SmsMessageStatus getStatus()
+    {
+        return status;
+    }
+
+    public void setStatus( SmsMessageStatus status )
+    {
+        this.status = status;
+    }
+
+    public String getStatusMessage()
+    {
+        return statusMessage;
+    }
+
+    public void setStatusMessage( String statusMessage )
+    {
+        this.statusMessage = statusMessage;
+    }
+
+}
\ No newline at end of file

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/IncomingSmsService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/IncomingSmsService.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/IncomingSmsService.java	2011-12-15 08:46:42 +0000
@@ -0,0 +1,50 @@
+package org.hisp.dhis.sms.incoming;
+
+/*
+ * Copyright (c) 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.
+ */
+
+
+/**
+ * Service providing support for retrieving incoming SMSes.
+ */
+public interface IncomingSmsService
+{
+
+    String ID = IncomingSmsService.class.getName();
+
+    /**
+     * Get the next sms incoming for processing, if any.
+     * 
+     * @return the oldest sms in the INCOMING state.
+     */
+    public IncomingSms getNextUnprocessed();
+
+    public IncomingSms get(int id);
+    
+    public void update( IncomingSms sms );
+
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/IncomingSmsStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/IncomingSmsStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/IncomingSmsStore.java	2011-12-15 08:46:42 +0000
@@ -0,0 +1,57 @@
+package org.hisp.dhis.sms.incoming;
+
+/*
+ * Copyright (c) 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.util.Collection;
+
+/** 
+ * Store for incoming SMS messages.
+ */
+public interface IncomingSmsStore
+{
+
+    public static final String ID = IncomingSmsStore.class.getName();
+    
+    public int save( IncomingSms incomingSms );
+
+    public IncomingSms get( int id );
+
+    public Collection<IncomingSms> getSmsByStatus( SmsMessageStatus status );
+
+    public Collection<IncomingSms> getSmsByOriginator( String originator );
+
+    public long getSmsCount();
+
+    public Collection<IncomingSms> getAllSmses();
+
+//    public Collection<IncomingSms> getSms( String originator, Date startDate, Date endDate);
+//    
+//    public Collection<IncomingSms> getSmsByDate( Date startDate, Date endDate );
+//
+
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/SmsMessageEncoding.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/SmsMessageEncoding.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/SmsMessageEncoding.java	2011-12-15 08:46:42 +0000
@@ -0,0 +1,51 @@
+package org.hisp.dhis.sms.incoming;
+
+/*
+ * Copyright (c) 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.
+ */
+
+/**
+ * Enumeration representing available SMS message encodings.
+ */
+public enum SmsMessageEncoding
+{
+        /**
+         * 7 bit encoding - standard GSM alphabet.
+         */
+        ENC7BIT,
+        /**
+         * 8 bit encoding.
+         */
+        ENC8BIT,
+        /**
+         * UCS2 (Unicode) encoding.
+         */
+        ENCUCS2,
+        /**
+         * Custom encoding. Currently just defaults to 7-bit.
+         */
+        ENCCUSTOM
+}
\ No newline at end of file

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/SmsMessageStatus.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/SmsMessageStatus.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/SmsMessageStatus.java	2011-12-15 08:46:42 +0000
@@ -0,0 +1,37 @@
+package org.hisp.dhis.sms.incoming;
+
+/*
+ * Copyright (c) 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.
+ */
+
+/**
+ * Status of an incoming sms.
+ */
+public enum SmsMessageStatus
+{
+    INCOMING, PROCESSING, UNHANDLED, FAILED, PROCESSED;
+    
+}

=== added directory 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound'
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSms.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSms.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSms.java	2011-12-15 08:46:42 +0000
@@ -0,0 +1,128 @@
+package org.hisp.dhis.sms.outbound;
+
+/*
+ * Copyright (c) 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.util.Collections;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+public class OutboundSms
+{
+
+    private int id;
+
+    private Set<String> recipients;
+
+    private Date date;
+
+    private String message;
+
+    private OutboundSmsStatus status = OutboundSmsStatus.OUTBOUND;
+
+    public OutboundSms()
+    {
+    }
+
+    public OutboundSms( String msg, String... recipients )
+    {
+        message = msg;
+        this.recipients = new HashSet<String>();
+        Collections.addAll( this.recipients, recipients );
+    }
+
+    public int getId()
+    {
+        return id;
+    }
+
+    public void setId( int id )
+    {
+        this.id = id;
+    }
+
+    public Set<String> getRecipients()
+    {
+        return recipients;
+    }
+
+    public void setRecipients( Set<String> recipients )
+    {
+        this.recipients = recipients;
+    }
+
+    public Date getDate()
+    {
+        return date;
+    }
+
+    public void setDate( Date date )
+    {
+        this.date = date;
+    }
+
+    public String getMessage()
+    {
+        return message;
+    }
+
+    public void setMessage( String message )
+    {
+        this.message = message;
+    }
+
+    public OutboundSmsStatus getStatus()
+    {
+        return status;
+    }
+
+    public void setStatus( OutboundSmsStatus status )
+    {
+        this.status = status;
+    }
+
+    @Override
+    public String toString()
+    {
+        return "OutboundSMS [recipients=" + getNumbers() + ", message=" + message + "]";
+    }
+
+    private String getNumbers()
+    {
+        if ( this.recipients == null )
+            return null;
+
+        String numbers = "";
+
+        for ( String recipient : this.recipients )
+        {
+            numbers += recipient + ", ";
+        }
+        return numbers.substring( 0, numbers.length() - 2 );
+    }
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsService.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsService.java	2011-12-15 08:46:42 +0000
@@ -0,0 +1,52 @@
+package org.hisp.dhis.sms.outbound;
+
+/*
+ * Copyright (c) 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 org.hisp.dhis.sms.SmsServiceException;
+import org.hisp.dhis.sms.config.SmsConfigurable;
+
+/**
+ * OutboundSmsService provides support for sending SMSes.
+ */
+public interface OutboundSmsService extends SmsConfigurable
+{
+
+    String ID = OutboundSmsService.class.getName();
+
+    public boolean isEnabled();
+
+    /**
+     * Send an SMS message.
+     * 
+     * @param sms the message to be sent
+     * @throws SmsServiceException if unable to sent Message
+     */
+    public void sendMessage( OutboundSms sms )
+        throws SmsServiceException;
+
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsStatus.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsStatus.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsStatus.java	2011-12-15 08:46:42 +0000
@@ -0,0 +1,35 @@
+package org.hisp.dhis.sms.outbound;
+
+/*
+ * Copyright (c) 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.
+ */
+
+public enum OutboundSmsStatus
+{
+
+    OUTBOUND, SENT, ERROR;
+    
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsStore.java	2011-12-15 08:46:42 +0000
@@ -0,0 +1,43 @@
+package org.hisp.dhis.sms.outbound;
+
+import java.util.List;
+
+/*
+ * Copyright (c) 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.
+ */
+
+public interface OutboundSmsStore
+{
+
+    public int save( OutboundSms sms );
+
+    public List<OutboundSms> getAll();
+
+    public OutboundSms get( int id );
+    
+    
+    
+}

=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsTransportService.java	2011-12-15 08:46:42 +0000
@@ -0,0 +1,10 @@
+package org.hisp.dhis.sms.outbound;
+
+
+/**
+ * Marker interface for {@code OutboundSmsService outbound sms services} providing actual sms sending.
+ */
+public interface OutboundSmsTransportService extends OutboundSmsService
+{
+    
+}

=== removed directory 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms'
=== removed file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/BulkSmsGatewayConfig.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/BulkSmsGatewayConfig.java	2011-11-04 11:27:33 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/BulkSmsGatewayConfig.java	1970-01-01 00:00:00 +0000
@@ -1,59 +0,0 @@
-package org.hisp.dhis.api.sms;
-
-/*
- * Copyright (c) 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.
- */
-
-public class BulkSmsGatewayConfig
-    extends SmsGatewayConfig
-{
-
-    private static final long serialVersionUID = 5249703354480948250L;
-
-    private String username;
-    private String password;
-    
-    public String getUsername()
-    {
-        return username;
-    }
-
-    public void setUsername( String username )
-    {
-        this.username = username;
-    }
-
-    public String getPassword()
-    {
-        return password;
-    }
-
-    public void setPassword( String password )
-    {
-        this.password = password;
-    }
-    
-}

=== removed file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/ClickatellGatewayConfig.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/ClickatellGatewayConfig.java	2011-11-04 11:27:33 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/ClickatellGatewayConfig.java	1970-01-01 00:00:00 +0000
@@ -1,70 +0,0 @@
-package org.hisp.dhis.api.sms;
-
-/*
- * Copyright (c) 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.
- */
-
-public class ClickatellGatewayConfig
-    extends SmsGatewayConfig
-{
-
-    private static final long serialVersionUID = -4286107769356591957L;
-
-    private String username;
-    private String password;
-    private String apiId;
-    
-    public String getUsername()
-    {
-        return username;
-    }
-
-    public void setUsername( String username )
-    {
-        this.username = username;
-    }
-
-    public String getPassword()
-    {
-        return password;
-    }
-
-    public void setPassword( String password )
-    {
-        this.password = password;
-    }
-
-    public String getApiId()
-    {
-        return apiId;
-    }
-
-    public void setApiId( String apiId )
-    {
-        this.apiId = apiId;
-    }
-
-}

=== removed file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/IncomingSms.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/IncomingSms.java	2011-11-04 11:27:33 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/IncomingSms.java	1970-01-01 00:00:00 +0000
@@ -1,183 +0,0 @@
-package org.hisp.dhis.api.sms;
-
-/*
- * Copyright (c) 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;
-import java.util.Date;
-
-public class IncomingSms
-    implements Serializable
-{
-
-    private static final long serialVersionUID = 3954710607630454226L;
-
-    private Integer id;
-
-    private SmsMessageEncoding encoding;
-
-    private Date sentDate;
-
-    private Date receivedDate;
-
-    /*
-     * The originator of the received message.
-     */
-    private String originator;
-
-    /*
-     * The ID of the gateway from which the message was received.
-     */
-    private String gatewayId;
-
-    private String text;
-
-    private byte[] bytes;
-
-    private SmsMessageStatus status = SmsMessageStatus.INCOMING;
-
-    private String statusMessage;
-
-    /**
-     * Incoming smses are one of two types, text or binary.
-     * 
-     * @return is this message a text (not binary) message?
-     */
-    public boolean isTextSms()
-    {
-        return text != null;
-    }
-
-    public Integer getId()
-    {
-        return id;
-    }
-
-    public void setId( Integer id )
-    {
-        this.id = id;
-    }
-
-    public SmsMessageEncoding getEncoding()
-    {
-        return encoding;
-    }
-
-    public void setEncoding( SmsMessageEncoding encoding )
-    {
-        this.encoding = encoding;
-    }
-
-    public Date getSentDate()
-    {
-        return sentDate;
-    }
-
-    public void setSentDate( Date sentDate )
-    {
-        this.sentDate = sentDate;
-    }
-
-    public Date getReceivedDate()
-    {
-        return receivedDate;
-    }
-
-    public void setReceivedDate( Date receivedDate )
-    {
-        this.receivedDate = receivedDate;
-    }
-
-    public String getOriginator()
-    {
-        return originator;
-    }
-
-    public void setOriginator( String originator )
-    {
-        this.originator = originator;
-    }
-
-    public String getGatewayId()
-    {
-        return gatewayId;
-    }
-
-    public void setGatewayId( String gatewayId )
-    {
-        this.gatewayId = gatewayId;
-    }
-
-    public String getText()
-    {
-        return text;
-    }
-
-    public void setText( String text )
-    {
-        if ( bytes != null )
-        {
-            throw new IllegalArgumentException("Text and bytes cannot both be set on incoming sms");
-        }
-        this.text = text;
-    }
-
-    public byte[] getBytes()
-    {
-        return bytes;
-    }
-
-    public void setBytes( byte[] bytes )
-    {
-        if ( text != null )
-        {
-            throw new IllegalArgumentException("Text and bytes cannot both be set on incoming sms");
-        }
-        this.bytes = bytes;
-    }
-
-    public SmsMessageStatus getStatus()
-    {
-        return status;
-    }
-
-    public void setStatus( SmsMessageStatus status )
-    {
-        this.status = status;
-    }
-
-    public String getStatusMessage()
-    {
-        return statusMessage;
-    }
-
-    public void setStatusMessage( String statusMessage )
-    {
-        this.statusMessage = statusMessage;
-    }
-
-}
\ No newline at end of file

=== removed file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/IncomingSmsService.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/IncomingSmsService.java	2011-11-04 11:27:33 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/IncomingSmsService.java	1970-01-01 00:00:00 +0000
@@ -1,48 +0,0 @@
-package org.hisp.dhis.api.sms;
-
-/*
- * Copyright (c) 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.
- */
-
-
-/**
- * Service providing support for retrieving incoming SMSes.
- */
-public interface IncomingSmsService
-{
-
-    String ID = IncomingSmsService.class.getName();
-
-    /**
-     * Check out the next sms incoming for processing, if any.
-     * 
-     * @return the oldest sms still in the INCOMING state.
-     */
-    public IncomingSms getNextIncomingSms();
-
-    public void setSmsStatus( int id, SmsMessageStatus status, String message );
-
-}

=== removed file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/IncomingSmsStore.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/IncomingSmsStore.java	2011-11-04 11:27:33 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/IncomingSmsStore.java	1970-01-01 00:00:00 +0000
@@ -1,57 +0,0 @@
-package org.hisp.dhis.api.sms;
-
-/*
- * Copyright (c) 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.util.Collection;
-
-/** 
- * Store for incoming SMS messages.
- */
-public interface IncomingSmsStore
-{
-
-    public static final String ID = IncomingSmsStore.class.getName();
-    
-    public int save( IncomingSms incomingSms );
-
-    public IncomingSms get( Integer id );
-
-    public Collection<IncomingSms> getSmsByStatus( SmsMessageStatus status );
-
-    public Collection<IncomingSms> getSmsByOriginator( String originator );
-
-    public long getSmsCount();
-
-    public Collection<IncomingSms> getAllSmses();
-
-//    public Collection<IncomingSms> getSms( String originator, Date startDate, Date endDate);
-//    
-//    public Collection<IncomingSms> getSmsByDate( Date startDate, Date endDate );
-//
-
-}

=== removed file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/ModemGateway.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/ModemGateway.java	2011-11-04 11:27:33 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/ModemGateway.java	1970-01-01 00:00:00 +0000
@@ -1,132 +0,0 @@
-package org.hisp.dhis.api.sms;
-
-/*
- * Copyright (c) 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.
- */
-
-public class ModemGateway
-    extends SmsGatewayConfig
-{
-
-    private static final long serialVersionUID = 5824899163489665038L;
-
-    private String port;
-
-    private int baudRate;
-
-    private String manufacturer;
-
-    private String model;
-
-    private String pin;
-
-    private boolean inbound;
-
-    private boolean outbound;
-
-    private String simMemLocation;
-
-    public String getPort()
-    {
-        return port;
-    }
-
-    public void setPort( String port )
-    {
-        this.port = port;
-    }
-
-    public int getBaudRate()
-    {
-        return baudRate;
-    }
-
-    public void setBaudRate( int baudRate )
-    {
-        this.baudRate = baudRate;
-    }
-
-    public String getManufacturer()
-    {
-        return manufacturer;
-    }
-
-    public void setManufacturer( String manufacturer )
-    {
-        this.manufacturer = manufacturer;
-    }
-
-    public String getModel()
-    {
-        return model;
-    }
-
-    public void setModel( String model )
-    {
-        this.model = model;
-    }
-
-    public String getPin()
-    {
-        return pin;
-    }
-
-    public void setPin( String pin )
-    {
-        this.pin = pin;
-    }
-
-    public boolean isInbound()
-    {
-        return inbound;
-    }
-
-    public void setInbound( boolean inbound )
-    {
-        this.inbound = inbound;
-    }
-
-    public boolean isOutbound()
-    {
-        return outbound;
-    }
-
-    public void setOutbound( boolean outbound )
-    {
-        this.outbound = outbound;
-    }
-
-    public String getSimMemLocation()
-    {
-        return simMemLocation;
-    }
-
-    public void setSimMemLocation( String simMemLocation )
-    {
-        this.simMemLocation = simMemLocation;
-    }
-
-}

=== removed file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/OutboundSMS.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/OutboundSMS.java	2011-12-07 15:08:33 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/OutboundSMS.java	1970-01-01 00:00:00 +0000
@@ -1,109 +0,0 @@
-package org.hisp.dhis.api.sms;
-
-/*
- * Copyright (c) 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.util.Date;
-import java.util.Set;
-
-public class OutboundSMS
-{
-
-    private Set<String> recipients;
-
-    private Date date;
-
-    private String message;
-    
-    private String prompt;
-    
-    private String url;
-    
-    private OutboundSmsStatus status = OutboundSmsStatus.OUTBOUND;
-
-    public Set<String> getRecipients()
-    {
-        return recipients;
-    }
-
-    public void setRecipients( Set<String> recipients )
-    {
-        this.recipients = recipients;
-    }
-
-    public Date getDate()
-    {
-        return date;
-    }
-
-    public void setDate( Date date )
-    {
-        this.date = date;
-    }
-
-    public String getMessage()
-    {
-        return message;
-    }
-
-    public void setMessage( String message )
-    {
-        this.message = message;
-    }
-
-    public String getPrompt()
-    {
-        return prompt;
-    }
-
-    public void setPrompt( String prompt )
-    {
-        this.prompt = prompt;
-    }
-
-    public String getUrl()
-    {
-        return url;
-    }
-
-    public void setUrl( String url )
-    {
-        this.url = url;
-    }
-
-    public OutboundSmsStatus getStatus()
-    {
-        return status;
-    }
-
-    public void setStatus( OutboundSmsStatus status )
-    {
-        this.status = status;
-    }
-    
-    
-}

=== removed file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/OutboundSmsService.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/OutboundSmsService.java	2011-12-07 15:08:33 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/OutboundSmsService.java	1970-01-01 00:00:00 +0000
@@ -1,69 +0,0 @@
-package org.hisp.dhis.api.sms;
-
-/*
- * Copyright (c) 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.net.URL;
-
-/**
- * OutboundSmsService provides support for sending SMSes.
- */
-public interface OutboundSmsService
-{
-
-    String ID = OutboundSmsService.class.getName();
-
-    /**
-     * Check if sending smses is possible.
-     * 
-     * @return true is sending smses is available.
-     */
-    public boolean isSmsServiceAvailable();
-
-    /**
-     * Send an SMS message to the list of recipients.
-     * 
-     * @param message the message to be sent
-     * @param recipients The phone numbers to send to
-     * @throws SmsServiceException if unable to sent Message
-     */
-    public void sendMessage( String message, String... recipients )
-        throws SmsServiceException;
-
-    /**
-     * Send an Over-the-Air (OTA) message. Used to enable download of settings,
-     * applications or sending multimedia messages
-     * 
-     * @param url The download URL to send
-     * @param prompt The message to be displayed to the recipients
-     * @param recipients The phone numbers to send to
-     * @throws SmsServiceException if unable to sent Message
-     */
-    public void sendOtaMessage( URL url, String prompt, String... recipients )
-        throws SmsServiceException;
-
-}

=== removed file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/OutboundSmsStatus.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/OutboundSmsStatus.java	2011-11-04 11:27:33 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/OutboundSmsStatus.java	1970-01-01 00:00:00 +0000
@@ -1,35 +0,0 @@
-package org.hisp.dhis.api.sms;
-
-/*
- * Copyright (c) 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.
- */
-
-public enum OutboundSmsStatus
-{
-
-    OUTBOUND, SENT, ERROR;
-    
-}

=== removed file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/OutboundSmsStore.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/OutboundSmsStore.java	2011-11-04 11:27:33 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/OutboundSmsStore.java	1970-01-01 00:00:00 +0000
@@ -1,37 +0,0 @@
-package org.hisp.dhis.api.sms;
-
-/*
- * Copyright (c) 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.
- */
-
-public interface OutboundSmsStore
-{
-
-    public int save( OutboundSMS sms );
-    
-    
-    
-}

=== removed file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/SmsConfig.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/SmsConfig.java	2011-11-04 11:27:33 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/SmsConfig.java	1970-01-01 00:00:00 +0000
@@ -1,79 +0,0 @@
-package org.hisp.dhis.api.sms;
-
-/*
- * Copyright (c) 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;
-import java.util.List;
-
-/**
- * Serializable configuration object for smsLib.
- */
-public class SmsConfig implements Serializable
-{
-
-    private static final long serialVersionUID = 7460688383539123303L;
-
-    private String longNumber;
-    
-    private List<SmsGatewayConfig> gateways;
-    
-    private int pollingInterval;
-    
-    public String getLongNumber()
-    {
-        return longNumber;
-    }
-
-    public void setLongNumber( String longNumber )
-    {
-        this.longNumber = longNumber;
-    }
-
-    public List<SmsGatewayConfig> getGateways()
-    {
-        return gateways;
-    }
-
-    public void setGateways( List<SmsGatewayConfig> gateways )
-    {
-        this.gateways = gateways;
-    }
-
-    public int getPollingInterval()
-    {
-        return pollingInterval;
-    }
-
-    public void setPollingInterval( int pollingInterval )
-    {
-        this.pollingInterval = pollingInterval;
-    }
-    
-
-    
-}

=== removed file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/SmsGatewayConfig.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/SmsGatewayConfig.java	2011-11-04 11:27:33 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/SmsGatewayConfig.java	1970-01-01 00:00:00 +0000
@@ -1,51 +0,0 @@
-package org.hisp.dhis.api.sms;
-
-/*
- * Copyright (c) 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;
-
-/**
- * Super class for gateway configurations
- */
-@SuppressWarnings( "serial" )
-public abstract class SmsGatewayConfig implements Serializable
-{
-    
-    private String name;
-
-    public String getName()
-    {
-        return name;
-    }
-
-    public void setName( String name )
-    {
-        this.name = name;
-    }
-    
-}

=== removed file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/SmsMessageEncoding.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/SmsMessageEncoding.java	2011-11-04 11:27:33 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/SmsMessageEncoding.java	1970-01-01 00:00:00 +0000
@@ -1,51 +0,0 @@
-package org.hisp.dhis.api.sms;
-
-/*
- * Copyright (c) 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.
- */
-
-/**
- * Enumeration representing available SMS message encodings.
- */
-public enum SmsMessageEncoding
-{
-        /**
-         * 7 bit encoding - standard GSM alphabet.
-         */
-        ENC7BIT,
-        /**
-         * 8 bit encoding.
-         */
-        ENC8BIT,
-        /**
-         * UCS2 (Unicode) encoding.
-         */
-        ENCUCS2,
-        /**
-         * Custom encoding. Currently just defaults to 7-bit.
-         */
-        ENCCUSTOM
-}
\ No newline at end of file

=== removed file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/SmsMessageStatus.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/SmsMessageStatus.java	2011-11-04 11:27:33 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/SmsMessageStatus.java	1970-01-01 00:00:00 +0000
@@ -1,37 +0,0 @@
-package org.hisp.dhis.api.sms;
-
-/*
- * Copyright (c) 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.
- */
-
-/**
- * Status of an incoming sms.
- */
-public enum SmsMessageStatus
-{
-    INCOMING, PROCESSING, UNHANDLED, FAILED, PROCESSED;
-    
-}

=== removed file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/SmsService.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/SmsService.java	2011-11-04 11:27:33 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/SmsService.java	1970-01-01 00:00:00 +0000
@@ -1,57 +0,0 @@
-package org.hisp.dhis.api.sms;
-
-/*
- * Copyright (c) 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.util.List;
-
-/**
- * Interface for service providing SMS messaging.
- */
-public interface SmsService
-{
-
-    public boolean isRunning();
-
-    public void start(SmsConfig config)
-        throws SmsServiceException;
-
-    public void stop()
-        throws SmsServiceException;
-
-    public void deleteMessage( IncomingSms sms )
-        throws SmsServiceException;
-
-    public List<IncomingSms> readMessages()
-        throws SmsServiceException;
-
-    public void sendMessage( OutboundSMS sms )
-        throws SmsServiceException;
-
-    public SmsConfig getConfig();
-
-}
\ No newline at end of file

=== removed file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/SmsServiceException.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/SmsServiceException.java	2011-11-04 11:27:33 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/sms/SmsServiceException.java	1970-01-01 00:00:00 +0000
@@ -1,50 +0,0 @@
-package org.hisp.dhis.api.sms;
-
-/*
- * Copyright (c) 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.
- */
-
-/**
- * This exception type is used for signaling any problems during SMS handling.
- */
-public class SmsServiceException
-    extends RuntimeException
-{
-
-    private static final long serialVersionUID = -7927288362330380301L;
-
-    public SmsServiceException( String message )
-    {
-        super( message );
-    }
-
-    public SmsServiceException( String message, Exception cause )
-    {
-        super( message, cause );
-    }
-
-    
-}

=== removed file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/SmsMessageSender.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/SmsMessageSender.java	2011-12-10 12:23:49 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/SmsMessageSender.java	1970-01-01 00:00:00 +0000
@@ -1,129 +0,0 @@
-package org.hisp.dhis.mobile.service;
-
-/*
- * Copyright (c) 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 static org.hisp.dhis.user.UserSettingService.KEY_MESSAGE_SMS_NOTIFICATION;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.api.sms.OutboundSmsService;
-import org.hisp.dhis.message.MessageSender;
-import org.hisp.dhis.user.User;
-import org.hisp.dhis.user.UserService;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class SmsMessageSender
-    implements MessageSender
-{
-    private static final Log log = LogFactory.getLog( SmsMessageSender.class );
-
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private UserService userService;
-
-    private OutboundSmsService outboundSmsService;
-
-    @Autowired
-    public void setUserService( UserService userService )
-    {
-        this.userService = userService;
-    }
-
-    @Autowired( required = false )
-    public void setOutboundSmsService( OutboundSmsService outboundSmsService )
-    {
-        this.outboundSmsService = outboundSmsService;
-        
-        log.info( "Found OutboundMessageService " + outboundSmsService.getClass().getSimpleName() + ". Enabling sms message sending.");
-    }
-
-    
-    // -------------------------------------------------------------------------
-    // MessageSender implementation
-    // -------------------------------------------------------------------------
-
-
-    @Override
-    public void sendMessage( String subject, String text, User sender, Set<User> users )
-    {
-
-        if ( outboundSmsService == null || !outboundSmsService.isSmsServiceAvailable() )
-        {
-            return;
-        }
-
-        String name = "unknown";
-        if ( sender != null )
-            name = sender.getUsername();
-
-        text = "From " + name + ", " + subject + ": " + text;
-
-        // Simplistic cutoff 160 characters..
-        int length = text.length();
-        if ( length > 160 )
-            text = text.substring( 0, 157 ) + "...";
-
-        Map<User, Serializable> settings = userService.getUserSettings( KEY_MESSAGE_SMS_NOTIFICATION, false );
-
-        List<String> recipients = new ArrayList<String>();
-
-        for ( User user : users )
-        {
-            boolean smsNotification = settings.get( user ) != null && (Boolean) settings.get( user );
-
-            String phoneNumber = user.getPhoneNumber();
-            if ( smsNotification && phoneNumber != null && !phoneNumber.trim().isEmpty() )
-            {
-                recipients.add( phoneNumber );
-                
-                if (log.isDebugEnabled())
-                    log.debug( "Adding user as sms recipient: " + user + " with phone number: " + phoneNumber );
-            }
-        }
-
-        if ( !recipients.isEmpty() )
-        {
-            outboundSmsService.sendMessage( text, recipients.toArray( new String[recipients.size()] ) );
-            if (log.isDebugEnabled()) {
-                log.debug( "Sent message to " + recipients + ": " + text );
-            }
-        } else if ( log.isDebugEnabled() ) {
-            log.debug( "No user to send message to" );
-        }
-
-    }
-
-}

=== removed file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/TestOutboundSmsService.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/TestOutboundSmsService.java	2011-12-10 12:23:49 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/TestOutboundSmsService.java	1970-01-01 00:00:00 +0000
@@ -1,43 +0,0 @@
-package org.hisp.dhis.mobile.service;
-
-import java.net.URL;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.api.sms.OutboundSmsService;
-import org.hisp.dhis.api.sms.SmsServiceException;
-
-public class TestOutboundSmsService
-    implements OutboundSmsService
-{
-
-    private static final Log log = LogFactory.getLog( TestOutboundSmsService.class );
-
-    @Override
-    public boolean isSmsServiceAvailable()
-    {
-        log.info( "Is service is available?" );
-        return true;
-    }
-
-    @Override
-    public void sendMessage( String message, String... recipients )
-        throws SmsServiceException
-    {
-        log.info( "Send message '" + message + "' to " + recipients);
-    }
-
-    @Override
-    public void sendOtaMessage( URL url, String prompt, String... recipients )
-        throws SmsServiceException
-    {
-        String numbers = "";
-        
-        for ( String recipient : recipients )
-        {
-            numbers += recipient + ", ";
-        }
-        log.info( "Send OTA message '" + prompt + "', url " + url + " to " + numbers.substring( 0, numbers.length() - 2 ) );
-    }
-
-}

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/resources/META-INF/dhis/beans.xml	2011-12-10 12:23:49 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/resources/META-INF/dhis/beans.xml	2011-12-15 08:46:42 +0000
@@ -45,12 +45,4 @@
     <property name="sessionFactory" ref="sessionFactory"/>
   </bean>
 
-  <!--  SMS Message sender -->
-
-  <bean id="org.hisp.dhis.mobile.service.SmsMessageSender" class="org.hisp.dhis.mobile.service.SmsMessageSender" />
-
-  <!--  OutboundSmsService stub just logging invocations, only to be used for testing! -->
-
-  <!-- <bean id="org.hisp.dhis.mobile.service.TestOutboundSmsService" class="org.hisp.dhis.mobile.service.TestOutboundSmsService" />  -->
-
 </beans>

=== removed directory 'dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service'
=== removed file 'dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service/SmsMessageSenderTest.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service/SmsMessageSenderTest.java	2011-12-07 21:25:57 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service/SmsMessageSenderTest.java	1970-01-01 00:00:00 +0000
@@ -1,65 +0,0 @@
-package org.hisp.dhis.mobile.service;
-
-import static org.hisp.dhis.user.UserSettingService.KEY_MESSAGE_SMS_NOTIFICATION;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-
-import org.hisp.dhis.api.sms.OutboundSmsService;
-import org.hisp.dhis.user.User;
-import org.hisp.dhis.user.UserService;
-import org.junit.Test;
-
-public class SmsMessageSenderTest
-{
-
-    
-    @Test
-    public void testMessageSender()
-    {
-
-        SmsMessageSender smsMessageSender = new SmsMessageSender();
-
-        OutboundSmsService outboundSmsService = mock( OutboundSmsService.class );
-        when( outboundSmsService.isSmsServiceAvailable() ).thenReturn( true );
-
-        UserService userService = mock( UserService.class );
-        final User user = getUser();
-        Map<User, Serializable> settings = getUserSettings( user );
-        when( userService.getUserSettings( KEY_MESSAGE_SMS_NOTIFICATION, false ) ).thenReturn( settings );
-
-        smsMessageSender.setOutboundSmsService( outboundSmsService );
-        smsMessageSender.setUserService( userService );
-        smsMessageSender.sendMessage( "Hello", "hello", user, getUserSet( user ) );
-
-        verify( outboundSmsService ).isSmsServiceAvailable();
-        verify( userService ).getUserSettings( KEY_MESSAGE_SMS_NOTIFICATION, false );
-        verify( outboundSmsService ).sendMessage( eq( "From null, Hello: hello" ), eq( "222222" ) );
-    }
-
-    private HashSet<User> getUserSet( final User user )
-    {
-        return new HashSet<User>() {{ add( user ); }};
-    }
-
-    private Map<User, Serializable> getUserSettings( final User user )
-    {
-        return new HashMap<User, Serializable>() {{ put( user, true ); }};
-    }
-
-    private User getUser()
-    {
-        final User user = new User();
-        user.setId( 1 );
-        user.setPhoneNumber( "222222" );
-        user.setFirstName( "firstName" );
-        user.setSurname( "surname" );
-        return user;
-    }
-}

=== added directory 'dhis-2/dhis-services/dhis-service-sms'
=== added file 'dhis-2/dhis-services/dhis-service-sms/pom.xml'
--- dhis-2/dhis-services/dhis-service-sms/pom.xml	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-sms/pom.xml	2011-12-15 20:41:45 +0000
@@ -0,0 +1,57 @@
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.hisp.dhis</groupId>
+    <artifactId>dhis-services</artifactId>
+    <version>2.6-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>dhis-service-sms</artifactId>
+  <packaging>jar</packaging>
+  <name>DHIS SMS Service</name>
+
+  <dependencies>
+
+    <!-- DHIS -->
+
+    <dependency>
+      <groupId>org.hisp.dhis</groupId>
+      <artifactId>dhis-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.hisp.dhis</groupId>
+      <artifactId>dhis-service-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.hisp.dhis</groupId>
+      <artifactId>dhis-service-administration</artifactId>
+    </dependency>
+<!--     <dependency>
+      <groupId>org.hamcrest</groupId>
+      <artifactId>hamcrest-library</artifactId>
+      <version>1.2.1</version>
+      <scope>test</scope>
+    </dependency>
+ -->
+        <!-- smslib -->
+    
+        <dependency>
+            <groupId>org.smslib</groupId>
+            <artifactId>smslib</artifactId>
+            <version>3.5.2-r2307</version>
+        </dependency>
+        <dependency>
+            <groupId>org.rxtx</groupId>
+            <artifactId>rxtx</artifactId>
+            <version>2.1.7</version>
+        </dependency>
+
+  </dependencies>
+
+  <properties>
+    <rootDir>../../</rootDir>
+  </properties>
+</project>

=== added directory 'dhis-2/dhis-services/dhis-service-sms/src'
=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/main'
=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/main/java'
=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org'
=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp'
=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis'
=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms'
=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/SmsConfigurationManagerImpl.java	2011-12-15 20:41:45 +0000
@@ -0,0 +1,80 @@
+package org.hisp.dhis.sms;
+
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.options.SystemSettingManager;
+import org.hisp.dhis.sms.SmsConfigurationManager;
+import org.hisp.dhis.sms.config.SmsConfigurable;
+import org.hisp.dhis.sms.config.SmsConfiguration;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * Manages the {@link SmsConfiguration} for the DHIS instance.
+ * <p>
+ * The manager looks up all beans implementing {@link SmsConfigurable} in the
+ * context, initializing them on startup and on any sms configuration changes.
+ * 
+ */
+public class SmsConfigurationManagerImpl implements SmsConfigurationManager
+{
+
+    private static final Log log = LogFactory.getLog( SmsConfigurationManagerImpl.class );
+
+    @Autowired
+    private SystemSettingManager systemSettingManager;
+
+    @Autowired( required = false )
+    private List<SmsConfigurable> smsConfigurables;
+
+    @PostConstruct
+    public void initializeSmsConfigurables()
+    {
+        if ( smsConfigurables == null )
+        {
+            return;
+        }
+
+        SmsConfiguration smsConfiguration = getSmsConfiguration();
+
+        if ( smsConfiguration == null )
+        {
+            return;
+        }
+        
+        for ( SmsConfigurable smsConfigurable : smsConfigurables )
+        {
+
+            try
+            {
+                smsConfigurable.initialize( smsConfiguration );
+                log.info( "Initialized " + smsConfigurable);
+            }
+            catch ( Throwable t )
+            {
+                // TODO: Need to make these problems available in GUI!
+                log.warn( "Unable to initialize service " + smsConfigurable.getClass().getSimpleName()
+                    + "with configuration " + smsConfiguration, t );
+            }
+        }
+
+    }
+
+    @Override
+    public SmsConfiguration getSmsConfiguration()
+    {
+        return (SmsConfiguration) systemSettingManager.getSystemSetting( SystemSettingManager.KEY_SMS_CONFIG );
+    }
+
+    @Override
+    public void updateSmsConfiguration( SmsConfiguration config )
+    {
+        systemSettingManager.saveSystemSetting( SystemSettingManager.KEY_SMS_CONFIG, config );
+
+        // Reinitialize components relying on sms config.
+        initializeSmsConfigurables();
+    }
+}

=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/incoming'
=== added file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/incoming/HibernateIncomingSmsStore.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/incoming/HibernateIncomingSmsStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/incoming/HibernateIncomingSmsStore.java	2011-12-15 08:46:42 +0000
@@ -0,0 +1,130 @@
+package org.hisp.dhis.sms.incoming;
+
+/*
+ * Copyright (c) 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.
+ *
+ * SmsHIS SOFSmsWARE IS PROVIDED BY SmsHE COPYRIGHSms HOLDERS AND CONSmsRIBUSmsORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANSmsIES, INCLUDING, BUSms NOSms LIMISmsED SmsO, SmsHE IMPLIED
+ * WARRANSmsIES OF MERCHANSmsABILISmsY AND FISmsNESS FOR A PARSmsICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENSms SHALL SmsHE COPYRIGHSms OWNER OR CONSmsRIBUSmsORS BE LIABLE FOR
+ * ANY DIRECSms, INDIRECSms, INCIDENSmsAL, SPECIAL, EXEMPLARY, OR CONSEQUENSmsIAL DAMAGES
+ * (INCLUDING, BUSms NOSms LIMISmsED SmsO, PROCUREMENSms OF SUBSSmsISmsUSmsE GOODS OR SERVICES;
+ * LOSS OF USE, DASmsA, OR PROFISmsS; OR BUSINESS INSmsERRUPSmsION) HOWEVER CAUSED AND ON
+ * ANY SmsHEORY OF LIABILISmsY, WHESmsHER IN CONSmsRACSms, SSmsRICSms LIABILISmsY, OR SmsORSms
+ * (INCLUDING NEGLIGENCE OR OSmsHERWISE) ARISING IN ANY WAY OUSms OF SmsHE USE OF SmsHIS
+ * SOFSmsWARE, EVEN IF ADVISED OF SmsHE POSSIBILISmsY OF SUCH DAMAGE.
+ */
+
+import java.util.Collection;
+
+import org.hibernate.Criteria;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.criterion.Projections;
+import org.hibernate.criterion.Restrictions;
+import org.hisp.dhis.sms.incoming.IncomingSms;
+import org.hisp.dhis.sms.incoming.IncomingSmsStore;
+import org.hisp.dhis.sms.incoming.SmsMessageStatus;
+
+@SuppressWarnings( "unchecked" )
+public class HibernateIncomingSmsStore
+    implements IncomingSmsStore
+{
+
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private SessionFactory sessionFactory;
+
+    public void setSessionFactory( SessionFactory sessionFactory )
+    {
+        this.sessionFactory = sessionFactory;
+    }
+
+    // -------------------------------------------------------------------------
+    // Implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public int save( IncomingSms sms )
+    {
+        return (Integer) sessionFactory.getCurrentSession().save( sms );
+    }
+
+    @Override
+    public IncomingSms get( int id )
+    {
+        Session session = sessionFactory.getCurrentSession();
+        return (IncomingSms) session.get( IncomingSms.class, id );
+    }
+
+    @Override
+    public Collection<IncomingSms> getSmsByStatus( SmsMessageStatus status )
+    {
+        Session session = sessionFactory.getCurrentSession();
+        Criteria criteria = session.createCriteria( IncomingSms.class ).add( Restrictions.eq( "status", status ) );
+        return (Collection<IncomingSms>) criteria.list();
+    }
+
+    @Override
+    public Collection<IncomingSms> getSmsByOriginator( String originator )
+    {
+        Criteria criteria = sessionFactory.getCurrentSession().createCriteria( IncomingSms.class );
+        criteria.add( Restrictions.eq( "originator", originator ) );
+        return criteria.list();
+    }
+
+    @Override
+    public Collection<IncomingSms> getAllSmses()
+    {
+        return sessionFactory.getCurrentSession().createCriteria( IncomingSms.class ).list();
+    }
+
+    @Override
+    public long getSmsCount()
+    {
+        Session session = sessionFactory.getCurrentSession();
+        Criteria criteria = session.createCriteria( IncomingSms.class );
+        criteria.setProjection( Projections.rowCount() );
+        Long count = (Long) criteria.uniqueResult();
+        return count != null ? count.longValue() : (long) 0;
+    }
+
+    // @Override
+    // public Collection<IncomingSms> getSms( String originator, Date startDate,
+    // Date endDate )
+    // {
+    // Criteria crit = sessionFactory.getCurrentSession().createCriteria(
+    // IncomingSms.class );
+    // if ( originator != null && !originator.equals( "" ) )
+    // {
+    // crit.add( Restrictions.eq( "originator", originator ) );
+    // }
+    // if ( startDate != null && endDate != null )
+    // {
+    // crit.add( Restrictions.between( "receiveDate", startDate, endDate ) );
+    // }
+    // return crit.list();
+    // }
+    //
+    // @Override
+    // public Collection<IncomingSms> getSmsByDate( Date startDate, Date endDate
+    // )
+    // {
+    // return getSms( null, startDate, endDate );
+    // }
+
+}

=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound'
=== added file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/HibernateOutboundSmsStore.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/HibernateOutboundSmsStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/HibernateOutboundSmsStore.java	2011-12-15 08:46:42 +0000
@@ -0,0 +1,53 @@
+package org.hisp.dhis.sms.outbound;
+
+import java.util.Date;
+import java.util.List;
+
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hisp.dhis.sms.outbound.OutboundSms;
+import org.hisp.dhis.sms.outbound.OutboundSmsStore;
+
+public class HibernateOutboundSmsStore
+    implements OutboundSmsStore
+{
+
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private SessionFactory sessionFactory;
+
+    public void setSessionFactory( SessionFactory sessionFactory )
+    {
+        this.sessionFactory = sessionFactory;
+    }
+
+    @Override
+    public int save( OutboundSms sms )
+    {
+        checkDate(sms);
+        return (Integer) sessionFactory.getCurrentSession().save( sms );
+    }
+    
+    private void checkDate( OutboundSms sms )
+    {
+        if (sms.getDate() == null) {
+            sms.setDate( new Date() );
+        }
+        
+    }
+
+    @Override
+    public OutboundSms get( int id) {
+        Session session = sessionFactory.getCurrentSession();
+        return (OutboundSms) session.get( OutboundSms.class, id );
+    }
+
+    @Override
+    @SuppressWarnings( "unchecked" )
+    public List<OutboundSms> getAll() {
+        Session session = sessionFactory.getCurrentSession();
+        return (List<OutboundSms>) session.createCriteria( OutboundSms.class ).list();
+    }
+}

=== added file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java	2011-12-15 20:41:45 +0000
@@ -0,0 +1,94 @@
+package org.hisp.dhis.sms.outbound;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.sms.SmsServiceException;
+import org.hisp.dhis.sms.SmsServiceNotEnabledException;
+import org.hisp.dhis.sms.config.SmsConfiguration;
+import org.hisp.dhis.sms.outbound.OutboundSms;
+import org.hisp.dhis.sms.outbound.OutboundSmsService;
+import org.hisp.dhis.sms.outbound.OutboundSmsStatus;
+import org.hisp.dhis.sms.outbound.OutboundSmsStore;
+import org.hisp.dhis.sms.outbound.OutboundSmsTransportService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Simple {@link OutboundSmsService sms service} storing the sms in a store and
+ * forwards the request to a {@link OutboundSmsTransportService sms transport
+ * service} for sending.
+ */
+public class OutboundSmsServiceImpl
+    implements OutboundSmsService
+{
+
+    private static final Log log = LogFactory.getLog( OutboundSmsServiceImpl.class );
+
+    private OutboundSmsStore outboundSmsStore;
+
+    private OutboundSmsTransportService transportService;
+
+    private boolean enabled;
+
+    @Autowired
+    public void setOutboundSmsStore( OutboundSmsStore outboundSmsStore )
+    {
+        this.outboundSmsStore = outboundSmsStore;
+    }
+
+    @Autowired( required = false )
+    protected void setTransportService( OutboundSmsTransportService transportService )
+    {
+        this.transportService = transportService;
+        log.info( "Got OutboundSmsTransportService: " + transportService.getClass().getSimpleName() );
+
+    }
+
+    @Override
+    public void initialize( SmsConfiguration smsConfiguration )
+        throws SmsServiceException
+    {
+        if ( smsConfiguration != null )
+        {
+            enabled = smsConfiguration.isEnabled();
+        }
+    }
+
+    @Override
+    public boolean isEnabled()
+    {
+        return enabled;
+    }
+
+    @Override
+    @Transactional
+    public void sendMessage( OutboundSms sms )
+        throws SmsServiceException
+    {
+        if ( !enabled )
+        {
+            throw new SmsServiceNotEnabledException();
+        }
+
+        outboundSmsStore.save( sms );
+
+        if ( transportService != null )
+        {
+            sendMessageInternal( sms );
+        }
+    }
+
+    private void sendMessageInternal( OutboundSms sms )
+    {
+        try
+        {
+            transportService.sendMessage( sms );
+            sms.setStatus( OutboundSmsStatus.SENT );
+        }
+        catch ( SmsServiceException e )
+        {
+            log.info( "Exception sending message " + sms, e );
+            sms.setStatus( OutboundSmsStatus.ERROR );
+        }
+    }
+}

=== added file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/SmsMessageSender.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/SmsMessageSender.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/SmsMessageSender.java	2011-12-15 08:46:42 +0000
@@ -0,0 +1,157 @@
+package org.hisp.dhis.sms.outbound;
+
+/*
+ * Copyright (c) 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 static org.hisp.dhis.user.UserSettingService.KEY_MESSAGE_SMS_NOTIFICATION;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.message.MessageSender;
+import org.hisp.dhis.sms.SmsServiceException;
+import org.hisp.dhis.sms.outbound.OutboundSms;
+import org.hisp.dhis.sms.outbound.OutboundSmsService;
+import org.hisp.dhis.user.User;
+import org.hisp.dhis.user.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class SmsMessageSender
+    implements MessageSender
+{
+    private static final Log log = LogFactory.getLog( SmsMessageSender.class );
+
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private UserService userService;
+
+    private OutboundSmsService outboundSmsService;
+
+    public void setUserService( UserService userService )
+    {
+        this.userService = userService;
+    }
+
+    public void setOutboundSmsService( OutboundSmsService outboundSmsService )
+    {
+        this.outboundSmsService = outboundSmsService;
+    }
+
+    // -------------------------------------------------------------------------
+    // MessageSender implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public void sendMessage( String subject, String text, User sender, Set<User> users )
+    {
+
+        if ( outboundSmsService == null || !outboundSmsService.isEnabled() )
+        {
+            return;
+        }
+
+        text = createMessage( subject, text, sender );
+
+        Set<String> recipients = getRecipients( users );
+
+        if ( !recipients.isEmpty() )
+        {
+            sendMessage( text, recipients );
+
+        }
+        else if ( log.isDebugEnabled() )
+        {
+            log.debug( "Not sending message to any of the recipients" );
+        }
+
+    }
+
+    private Set<String> getRecipients( Set<User> users )
+    {
+        Set<String> recipients = new HashSet<String>();
+
+        Map<User, Serializable> settings = userService.getUserSettings( KEY_MESSAGE_SMS_NOTIFICATION, false );
+
+        for ( User user : users )
+        {
+            boolean smsNotification = settings.get( user ) != null && (Boolean) settings.get( user );
+
+            String phoneNumber = user.getPhoneNumber();
+            if ( smsNotification && phoneNumber != null && !phoneNumber.trim().isEmpty() )
+            {
+                recipients.add( phoneNumber );
+
+                if ( log.isDebugEnabled() )
+                    log.debug( "Adding user as sms recipient: " + user + " with phone number: " + phoneNumber );
+            }
+        }
+        return recipients;
+    }
+
+    private String createMessage( String subject, String text, User sender )
+    {
+        String name = "unknown";
+        if ( sender != null )
+            name = sender.getUsername();
+
+        text = "From " + name + ", " + subject + ": " + text;
+
+        // Simplistic cutoff 160 characters..
+        int length = text.length();
+        if ( length > 160 )
+            text = text.substring( 0, 157 ) + "...";
+        return text;
+    }
+
+    private void sendMessage( String text, Set<String> recipients )
+    {
+        OutboundSms sms = new OutboundSms();
+        sms.setMessage( text );
+        sms.setRecipients( recipients );
+
+        try
+        {
+            outboundSmsService.sendMessage( sms );
+
+            if ( log.isDebugEnabled() )
+            {
+                log.debug( "Sent message to " + recipients + ": " + text );
+            }
+        }
+        catch ( SmsServiceException e )
+        {
+            log.warn( "Unable to send message through sms: " + sms, e );
+        }
+    }
+
+}

=== added file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/TestOutboundSmsService.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/TestOutboundSmsService.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/TestOutboundSmsService.java	2011-12-15 08:46:42 +0000
@@ -0,0 +1,49 @@
+package org.hisp.dhis.sms.outbound;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.sms.SmsServiceException;
+import org.hisp.dhis.sms.SmsServiceNotEnabledException;
+import org.hisp.dhis.sms.config.SmsConfiguration;
+import org.hisp.dhis.sms.outbound.OutboundSms;
+import org.hisp.dhis.sms.outbound.OutboundSmsService;
+import org.hisp.dhis.sms.outbound.OutboundSmsTransportService;
+
+/**
+ * Simple {@link OutboundSmsService} just logging invocations, only to be used for test purposes
+ * 
+ * <p>Has the property enabled, defaulting to true, which is configured using {@link TestOutboundSmsService#initialize(SmsConfiguration)}
+ */
+public class TestOutboundSmsService
+    implements OutboundSmsTransportService
+{
+
+    private static final Log log = LogFactory.getLog( TestOutboundSmsService.class );
+
+    private boolean enabled = true;
+
+    @Override
+    public void sendMessage( OutboundSms sms )
+        throws SmsServiceException
+    {
+        if (!enabled)
+            throw new SmsServiceNotEnabledException();
+            
+        log.info( "Send message: " + sms );
+    }
+
+    @Override
+    public void initialize(SmsConfiguration config)
+        throws SmsServiceException
+    {
+        this.enabled = config.isEnabled();
+        log.info( "initialize()" );
+    }
+
+    @Override
+    public boolean isEnabled()
+    {
+        return this.enabled;
+    }
+
+}

=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib'
=== added file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/GateWayFactory.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/GateWayFactory.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/GateWayFactory.java	2011-12-15 20:51:45 +0000
@@ -0,0 +1,73 @@
+package org.hisp.dhis.sms.smslib;
+
+import org.hisp.dhis.sms.SmsServiceException;
+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.SmsGatewayConfig;
+import org.smslib.AGateway;
+import org.smslib.AGateway.Protocols;
+import org.smslib.http.BulkSmsHTTPGateway;
+import org.smslib.http.ClickatellHTTPGateway;
+import org.smslib.modem.SerialModemGateway;
+
+public class GateWayFactory
+{
+
+    public AGateway create( SmsGatewayConfig config )
+    {
+        if ( config instanceof BulkSmsGatewayConfig )
+            return createBulkSmsGateway( (BulkSmsGatewayConfig) config );
+        else if ( config instanceof ClickatellGatewayConfig )
+            return createClickatellGateway( (ClickatellGatewayConfig) config );
+        else if ( config instanceof ModemGatewayConfig )
+            return createModemGateway( (ModemGatewayConfig) config );
+
+        throw new SmsServiceException( "Gateway config of unknown type: " + config.getClass().getName() );
+
+    }
+
+    public AGateway createBulkSmsGateway( BulkSmsGatewayConfig config )
+    {
+        BulkSmsHTTPGateway gateway = new BulkSmsHTTPGateway( "bulksms.http.1", config.getUsername(),
+            config.getPassword() );
+        gateway.setOutbound( true );
+        gateway.setInbound( false );
+        return gateway;
+    }
+
+    public AGateway createModemGateway( ModemGatewayConfig c )
+    {
+
+        // TODO: DETECT MODEM CLASS AND INSTANTIATE
+        SerialModemGateway gateway = new SerialModemGateway( c.getName(), c.getPort(), c.getBaudRate(),
+            c.getManufacturer(), c.getModel() );
+
+        if ( c.getSimMemLocation() != null )
+        {
+            gateway.getATHandler().setStorageLocations( c.getSimMemLocation() );
+        }
+
+        if ( c.getPin() != null )
+        {
+            gateway.setSimPin( c.getPin() );
+        }
+
+        gateway.setProtocol( Protocols.PDU );
+        gateway.setInbound( c.isInbound() );
+        gateway.setOutbound( c.isOutbound() );
+
+        return gateway;
+    }
+
+    public AGateway createClickatellGateway( ClickatellGatewayConfig c )
+    {
+        ClickatellHTTPGateway gateway = new ClickatellHTTPGateway( c.getName(), c.getApiId(), c.getUsername(),
+            c.getPassword() );
+        gateway.setOutbound( true );
+        gateway.setInbound( false );
+        return gateway;
+    }
+
+
+}

=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java	2011-12-15 20:41:45 +0000
@@ -0,0 +1,235 @@
+package org.hisp.dhis.sms.smslib;
+
+import java.io.IOException;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.sms.SmsServiceException;
+import org.hisp.dhis.sms.config.SmsConfiguration;
+import org.hisp.dhis.sms.config.SmsGatewayConfig;
+import org.hisp.dhis.sms.outbound.OutboundSms;
+import org.hisp.dhis.sms.outbound.OutboundSmsTransportService;
+import org.smslib.AGateway;
+import org.smslib.GatewayException;
+import org.smslib.IOutboundMessageNotification;
+import org.smslib.OutboundMessage;
+import org.smslib.SMSLibException;
+import org.smslib.Service;
+import org.smslib.Service.ServiceStatus;
+
+public class SmsLibService
+    implements OutboundSmsTransportService
+{
+
+    private static final Log log = LogFactory.getLog( SmsLibService.class );
+
+    private GateWayFactory gatewayFactory = new GateWayFactory();
+
+    private SmsConfiguration config;
+
+    @Override
+    public boolean isEnabled()
+    {
+        return config != null && config.isEnabled();
+    }
+
+    @Override
+    public void sendMessage( OutboundSms sms )
+        throws SmsServiceException
+    {
+        String recipient;
+
+        Set<String> recipients = sms.getRecipients();
+
+        if ( recipients.size() == 0 )
+        {
+            log.warn( "Trying to send sms without recipients: " + sms );
+            return;
+        }
+        else if ( recipients.size() == 1 )
+        {
+            recipient = recipients.iterator().next();
+        }
+        else
+        {
+            recipient = createTmpGroup( recipients );
+        }
+
+        OutboundMessage message = new OutboundMessage( recipient, sms.getMessage() );
+        String longNumber = config.getLongNumber();
+        if ( longNumber != null && !longNumber.isEmpty() )
+        {
+            message.setFrom( longNumber );
+        }
+
+        try
+        {
+            log.debug( "Sending message " + sms );
+            getService().sendMessage( message );
+        }
+        catch ( SMSLibException e )
+        {
+            log.warn( "Unable to send message: " + sms, e );
+            throw new SmsServiceException( "Unable to send message: " + sms, e );
+        }
+        catch ( IOException e )
+        {
+            log.warn( "Unable to send message: " + sms, e );
+            throw new SmsServiceException( "Unable to send message: " + sms, e );
+        }
+        catch ( InterruptedException e )
+        {
+            log.warn( "Unable to send message: " + sms, e );
+            throw new SmsServiceException( "Unable to send message: " + sms, e );
+        }
+        finally
+        {
+            if ( recipients.size() > 1 )
+            {
+                // Make sure we delete tmp. group
+                removeGroup( recipient );
+            }
+        }
+
+    }
+
+    @Override
+    public void initialize( SmsConfiguration smsConfiguration )
+        throws SmsServiceException
+    {
+        // FIXME: Implement a decent equals..
+        // if (smsConfiguration.equals( config )) {
+        // // nothing to do
+        // return;
+        // }
+
+        log.info( "Initializing SmsLib" );
+
+        this.config = smsConfiguration;
+
+        ServiceStatus status = getService().getServiceStatus();
+        if ( status == ServiceStatus.STARTED || status == ServiceStatus.STARTING )
+        {
+            log.info( "Stopping SmsLib" );
+            stopService();
+        }
+
+        log.info( "Loading configuration" );
+        reloadConfig();
+
+        if (config.isEnabled()) {
+        log.info( "Starting SmsLib" );
+        startService();
+        } else
+        {
+            log.info( "Sms not enabled, won't start service" );
+        }
+    }
+
+    private String createTmpGroup( Set<String> recipients )
+    {
+        String groupName = Thread.currentThread().getName();
+
+        getService().createGroup( groupName );
+        for ( String recepient : recipients )
+        {
+            getService().addToGroup( groupName, recepient );
+        }
+        return groupName;
+    }
+
+    private void removeGroup( String groupName )
+    {
+        getService().removeGroup( groupName );
+    }
+
+    private void startService()
+    {
+        try
+        {
+            getService().startService();
+        }
+        catch ( SMSLibException e )
+        {
+            log.warn( "Unable to start smsLib service", e );
+            throw new SmsServiceException( "Unable to start smsLib service", e );
+        }
+        catch ( IOException e )
+        {
+            log.warn( "Unable to start smsLib service", e );
+            throw new SmsServiceException( "Unable to start smsLib service", e );
+        }
+        catch ( InterruptedException e )
+        {
+            log.warn( "Unable to start smsLib service", e );
+            throw new SmsServiceException( "Unable to start smsLib service", e );
+        }
+    }
+
+    private void stopService()
+    {
+        try
+        {
+            getService().stopService();
+        }
+        catch ( SMSLibException e )
+        {
+            log.warn( "Unable to stop smsLib service", e );
+            throw new SmsServiceException( "Unable to stop smsLib service", e );
+        }
+        catch ( IOException e )
+        {
+            log.warn( "Unable to stop smsLib service", e );
+            throw new SmsServiceException( "Unable to stop smsLib service", e );
+        }
+        catch ( InterruptedException e )
+        {
+            log.warn( "Unable to stop smsLib service", e );
+            throw new SmsServiceException( "Unable to stop smsLib service", e );
+        }
+    }
+
+    private Service getService()
+    {
+        return Service.getInstance();
+    }
+
+    private void reloadConfig()
+        throws SmsServiceException
+    {
+        Service service = Service.getInstance();
+
+        service.setOutboundMessageNotification( new OutboundNotification() );
+        
+        service.getGateways().clear();
+
+        // Add gateways
+        for ( SmsGatewayConfig gatewayConfig : config.getGateways() )
+        {
+            try
+            {
+                service.addGateway( gatewayFactory.create( gatewayConfig ) );
+                log.info( "Added gateway " + gatewayConfig.getName() );
+            }
+            catch ( GatewayException e )
+            {
+                log.warn( "Unable to load gateway " + gatewayConfig.getName(), e );
+                throw new SmsServiceException( "Unable to load gateway" + gatewayConfig.getName(), e );
+            }
+        }
+    }
+
+    public class OutboundNotification
+        implements IOutboundMessageNotification
+    {
+
+        @Override
+        public void process( AGateway gateway, OutboundMessage msg )
+        {
+            log.info( "Sent message through gateway " + gateway.getGatewayId() + ": " + msg);
+
+        }
+    }
+
+}

=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/main/resources'
=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/main/resources/META-INF'
=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/main/resources/META-INF/dhis'
=== added file 'dhis-2/dhis-services/dhis-service-sms/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-sms/src/main/resources/META-INF/dhis/beans.xml	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/resources/META-INF/dhis/beans.xml	2011-12-15 20:41:45 +0000
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd";>
+
+  <bean id="org.hisp.dhis.sms.outbound.SmsConfigurationManager" class="org.hisp.dhis.sms.SmsConfigurationManagerImpl" />
+  
+  <!-- Outbound SMS service -->
+
+  <bean id="org.hisp.dhis.sms.outbound.OutboundSmsService" class="org.hisp.dhis.sms.outbound.OutboundSmsServiceImpl" />
+
+  <bean id="OutboundSmsStore" class="org.hisp.dhis.sms.outbound.HibernateOutboundSmsStore">
+    <property name="sessionFactory" ref="sessionFactory" />
+  </bean>
+  
+  <!--  Only for testing! OutboundSmsService stub just logging invocations, replacing the deafult one or use as the OutboundSmsTransportService..  -->
+  <!--  <bean id="TestOutboundSmsService" class="org.hisp.dhis.sms.outbound.TestOutboundSmsService" /> -->
+
+  <bean id="SmsLibService" class="org.hisp.dhis.sms.smslib.SmsLibService" />
+
+  <!--  SMS Message sender -->
+
+  <bean id="org.hisp.dhis.sms.outbound.SmsMessageSender" class="org.hisp.dhis.sms.outbound.SmsMessageSender">
+    <property name="outboundSmsService" ref="org.hisp.dhis.sms.outbound.OutboundSmsService" />
+    <property name="userService" ref="org.hisp.dhis.user.UserService" />
+  </bean>
+
+
+</beans>

=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/main/resources/org'
=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/main/resources/org/hisp'
=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/main/resources/org/hisp/dhis'
=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/main/resources/org/hisp/dhis/sms'
=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/main/resources/org/hisp/dhis/sms/incoming'
=== added file 'dhis-2/dhis-services/dhis-service-sms/src/main/resources/org/hisp/dhis/sms/incoming/IncomingSms.hbm.xml'
--- dhis-2/dhis-services/dhis-service-sms/src/main/resources/org/hisp/dhis/sms/incoming/IncomingSms.hbm.xml	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/resources/org/hisp/dhis/sms/incoming/IncomingSms.hbm.xml	2011-12-15 08:46:42 +0000
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd";>
+
+<hibernate-mapping>
+  <class name="org.hisp.dhis.sms.incoming.IncomingSms" table="incomingsms">
+
+    <id name="id">
+      <generator class="native" />
+    </id>
+
+    <property name="originator" index="sms_originator_index" not-null="true" />
+
+    <property name="encoding" not-null="true">
+      <type name="org.hibernate.type.EnumType">
+        <param name="enumClass">org.hisp.dhis.sms.incoming.SmsMessageEncoding</param>
+      </type>
+    </property>
+
+    <property name="sentDate" not-null="true" />
+
+    <property name="receivedDate" not-null="true" />
+
+    <property name="text" />
+
+    <property name="gatewayId" not-null="true" />
+
+    <property name="status" not-null="true" index="sms_status_index">
+      <type name="org.hibernate.type.EnumType">
+        <param name="enumClass">org.hisp.dhis.sms.outbound.OutboundSmsStatus</param>
+      </type>
+    </property>
+    
+    <property name="statusMessage" />
+
+  </class>
+</hibernate-mapping>

=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/main/resources/org/hisp/dhis/sms/outbound'
=== added file 'dhis-2/dhis-services/dhis-service-sms/src/main/resources/org/hisp/dhis/sms/outbound/OutboundSms.hbm.xml'
--- dhis-2/dhis-services/dhis-service-sms/src/main/resources/org/hisp/dhis/sms/outbound/OutboundSms.hbm.xml	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/resources/org/hisp/dhis/sms/outbound/OutboundSms.hbm.xml	2011-12-15 08:46:42 +0000
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd";>
+
+<hibernate-mapping>
+  <class name="org.hisp.dhis.sms.outbound.OutboundSms" table="outbound_sms">
+
+    <id name="id">
+      <generator class="native" />
+    </id>
+
+    <set name="recipients" table="outbound_sms_recipients">
+      <key column="outbound_sms_id" />
+      <element type="text"/>
+    </set>
+    
+    <property name="date" not-null="true" />
+
+    <property name="message" />
+
+    <property name="status" not-null="true" index="outbound_sms_status_index">
+      <type name="org.hibernate.type.EnumType">
+        <param name="enumClass">org.hisp.dhis.sms.outbound.OutboundSmsStatus</param>
+      </type>
+    </property>
+
+  </class>
+</hibernate-mapping>

=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/test'
=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/test/java'
=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/test/java/org'
=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp'
=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis'
=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms'
=== added file 'dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/AbstractSmsTest.java'
--- dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/AbstractSmsTest.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/AbstractSmsTest.java	2011-12-15 08:46:42 +0000
@@ -0,0 +1,61 @@
+package org.hisp.dhis.sms;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.hibernate.SessionFactory;
+import org.hisp.dhis.sms.outbound.OutboundSms;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.transaction.annotation.Transactional;
+
+@RunWith( SpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = { "classpath:/test-beans.xml" } )
+@Transactional
+public abstract class AbstractSmsTest
+{
+
+    @Autowired
+    protected SessionFactory sessionFactory;
+
+    protected void flush()
+    {
+        sessionFactory.getCurrentSession().flush();
+    }
+
+    protected void evict( Object o )
+    {
+        sessionFactory.getCurrentSession().evict( o );
+    }
+
+    protected OutboundSms getOutboundSms()
+    {
+        OutboundSms sms = new OutboundSms();
+        sms.setMessage( "1" );
+        Set<String> recipients = new HashSet<String>() {{ add("1"); add("2");}};
+        sms.setRecipients( recipients  );
+        return sms;
+    }
+
+    protected void verifySms( OutboundSms expected, OutboundSms actual )
+    {
+        assertNotNull(actual);
+        assertNotNull( actual.getDate() );
+        assertEquals( expected.getId(), actual.getId());
+        assertEquals( expected.getMessage(), actual.getMessage() );
+        assertEquals( expected.getRecipients(), actual.getRecipients() );
+    }
+
+    protected void assertNotNullSize( Collection<?> c, int i )
+    {
+        assertNotNull( c );
+        assertEquals(i, c.size());
+    }
+
+}

=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/outbound'
=== added file 'dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceTest.java'
--- dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceTest.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceTest.java	2011-12-15 20:41:45 +0000
@@ -0,0 +1,126 @@
+package org.hisp.dhis.sms.outbound;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import java.util.List;
+
+import org.hisp.dhis.sms.AbstractSmsTest;
+import org.hisp.dhis.sms.SmsServiceException;
+import org.hisp.dhis.sms.config.SmsConfiguration;
+import org.hisp.dhis.sms.outbound.OutboundSms;
+import org.hisp.dhis.sms.outbound.OutboundSmsService;
+import org.hisp.dhis.sms.outbound.OutboundSmsStatus;
+import org.hisp.dhis.sms.outbound.OutboundSmsStore;
+import org.hisp.dhis.sms.outbound.OutboundSmsTransportService;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class OutboundSmsServiceTest
+    extends AbstractSmsTest
+{
+
+    // These are only used for the integration test with store
+
+    @Autowired
+    private OutboundSmsService outboundSmsService;
+
+    @Autowired
+    private OutboundSmsStore outboundSmsStore;
+
+    @Test
+    public void testIntegrationEnabledNoTransport()
+    {
+        outboundSmsService.initialize( new SmsConfiguration( true ) );
+
+        OutboundSms outboundSms = getOutboundSms();
+
+        outboundSmsService.sendMessage( outboundSms );
+
+        List<OutboundSms> smses = outboundSmsStore.getAll();
+        assertNotNullSize( smses, 1 );
+
+        verifySms( outboundSms, smses.iterator().next() );
+    }
+
+    // Unit testing
+
+    @Test
+    public void testNotEnabled()
+    {
+        OutboundSmsService tmpService = new OutboundSmsServiceImpl();
+        try
+        {
+            tmpService.sendMessage( getOutboundSms() );
+            fail("Should fail since service is not enabled");
+        }
+        catch ( SmsServiceException e )
+        {
+        }
+
+    }
+
+    @Test
+    public void testWithTransport()
+    {
+        OutboundSmsServiceImpl tmpService = new OutboundSmsServiceImpl();
+        tmpService.setOutboundSmsStore( mock( OutboundSmsStore.class ) );
+        OutboundSmsTransportService transportService = mock( OutboundSmsTransportService.class );
+        tmpService.setTransportService( transportService );
+
+        OutboundSms outboundSms = getOutboundSms();
+   
+        // Service not enabled
+        try
+        {
+            tmpService.sendMessage( outboundSms );
+            fail("Should fail since service is not enabled");
+        }
+        catch ( SmsServiceException e )
+        {
+        }
+
+        // Not sent message to transport service
+        verify( transportService, never() ).sendMessage( any( OutboundSms.class ) );
+
+        // Enable service
+        tmpService.initialize( new SmsConfiguration( true ) );
+
+        tmpService.sendMessage( outboundSms );
+        verify( transportService ).sendMessage( outboundSms );
+    }
+
+    @Test
+    public void testFailingTransport()
+    {
+        OutboundSmsServiceImpl tmpService = new OutboundSmsServiceImpl();
+        OutboundSmsStore tmpStore = mock( OutboundSmsStore.class );
+        tmpService.setOutboundSmsStore( tmpStore );
+        OutboundSmsTransportService transportService = mock( OutboundSmsTransportService.class );
+        tmpService.setTransportService( transportService );
+
+        tmpService.initialize( new SmsConfiguration( true ) );
+
+        OutboundSms outboundSms = getOutboundSms();
+
+        doThrow( new SmsServiceException( "" ) ).when( transportService ).sendMessage( outboundSms );
+
+        tmpService.sendMessage( outboundSms );
+
+        verify( transportService ).sendMessage( outboundSms );
+        ArgumentCaptor<OutboundSms> argument = ArgumentCaptor.forClass( OutboundSms.class );
+        verify( tmpStore, times( 1 ) ).save( argument.capture() );
+
+        // Is the SMS Marked with error status in store?
+        // Can't test this without using hibernate or adding update on store...
+        //assertEquals( OutboundSmsStatus.ERROR, argument.getValue().getStatus() );
+    }
+
+}

=== added file 'dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/outbound/OutboundSmsStoreTest.java'
--- dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/outbound/OutboundSmsStoreTest.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/outbound/OutboundSmsStoreTest.java	2011-12-15 08:46:42 +0000
@@ -0,0 +1,34 @@
+package org.hisp.dhis.sms.outbound;
+
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.hisp.dhis.sms.AbstractSmsTest;
+import org.hisp.dhis.sms.outbound.OutboundSms;
+import org.hisp.dhis.sms.outbound.OutboundSmsStore;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class OutboundSmsStoreTest extends AbstractSmsTest
+{
+
+    @Autowired
+    private OutboundSmsStore outboundSmsStore;
+    
+    @Test
+    public void testSimpleSaveGet() {
+        OutboundSms sms = getOutboundSms();
+
+        int id = outboundSmsStore.save( sms );
+
+        flush();
+        evict( sms );
+        
+        OutboundSms outboundSms = outboundSmsStore.get( id );
+
+        verifySms( sms, outboundSms );
+    }
+
+    
+}

=== added file 'dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/outbound/SmsMessageSenderTest.java'
--- dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/outbound/SmsMessageSenderTest.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/test/java/org/hisp/dhis/sms/outbound/SmsMessageSenderTest.java	2011-12-15 08:46:42 +0000
@@ -0,0 +1,76 @@
+package org.hisp.dhis.sms.outbound;
+
+import static org.hisp.dhis.user.UserSettingService.KEY_MESSAGE_SMS_NOTIFICATION;
+import static org.mockito.Matchers.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+
+import org.hisp.dhis.sms.outbound.OutboundSms;
+import org.hisp.dhis.sms.outbound.OutboundSmsService;
+import org.hisp.dhis.sms.outbound.SmsMessageSender;
+import org.hisp.dhis.user.User;
+import org.hisp.dhis.user.UserService;
+import org.junit.Test;
+
+@SuppressWarnings( "serial" )
+public class SmsMessageSenderTest
+{
+    
+    @Test
+    public void testMessageSender()
+    {
+        OutboundSms sms = getSms();
+        final User user = getUser();
+        Map<User, Serializable> settings = getUserSettings( user );
+
+        SmsMessageSender smsMessageSender = new SmsMessageSender();
+
+        OutboundSmsService outboundSmsService = mock( OutboundSmsService.class );
+        when( outboundSmsService.isEnabled() ).thenReturn( true );
+
+        UserService userService = mock( UserService.class );
+        when( userService.getUserSettings( KEY_MESSAGE_SMS_NOTIFICATION, false ) ).thenReturn( settings );
+
+        smsMessageSender.setOutboundSmsService( outboundSmsService );
+        smsMessageSender.setUserService( userService );
+        smsMessageSender.sendMessage( "Hello", "hello", user, getUserSet( user ) );
+
+        verify( outboundSmsService ).isEnabled();
+        verify( userService ).getUserSettings( KEY_MESSAGE_SMS_NOTIFICATION, false );
+        verify( outboundSmsService ).sendMessage( refEq(sms) );
+    }
+
+    private OutboundSms getSms()
+    {
+        OutboundSms sms = new OutboundSms();
+        sms.setMessage( "From null, Hello: hello" );
+        sms.setRecipients( new HashSet<String>() {{ add("222222");}} );
+        return sms;
+    }
+
+    private HashSet<User> getUserSet( final User user )
+    {
+        return new HashSet<User>() {{ add( user ); }};
+    }
+
+    private Map<User, Serializable> getUserSettings( final User user )
+    {
+        return new HashMap<User, Serializable>() {{ put( user, true ); }};
+    }
+
+    private User getUser()
+    {
+        final User user = new User();
+        user.setId( 1 );
+        user.setPhoneNumber( "222222" );
+        user.setFirstName( "firstName" );
+        user.setSurname( "surname" );
+        return user;
+    }
+}

=== added directory 'dhis-2/dhis-services/dhis-service-sms/src/test/resources'
=== added file 'dhis-2/dhis-services/dhis-service-sms/src/test/resources/test-beans.xml'
--- dhis-2/dhis-services/dhis-service-sms/src/test/resources/test-beans.xml	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/test/resources/test-beans.xml	2011-12-15 08:46:42 +0000
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xmlns:tx="http://www.springframework.org/schema/tx";
+       xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd";>
+  
+  <bean id="org.hisp.dhis.sms.outbound.OutboundSmsService" class="org.hisp.dhis.sms.outbound.OutboundSmsServiceImpl" />
+  
+  <bean id="IncomingSmsStore" class="org.hisp.dhis.sms.incoming.HibernateIncomingSmsStore">
+    <property name="sessionFactory" ref="sessionFactory" />
+  </bean>
+
+  <bean id="OutboundSmsStore" class="org.hisp.dhis.sms.outbound.HibernateOutboundSmsStore">
+    <property name="sessionFactory" ref="sessionFactory" />
+  </bean>
+  
+  <!-- Hibernate -->
+  
+  <tx:annotation-driven transaction-manager="transactionManager"/>
+  
+  <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
+    <property name="sessionFactory" ref="sessionFactory"/>
+    <property name="dataSource" ref="dataSource"/>
+  </bean>
+  
+  <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
+    <property name="dataSource" ref="dataSource"/>
+    <property name="mappingResources">
+      <list>
+        <value>org/hisp/dhis/sms/incoming/IncomingSms.hbm.xml</value>
+        <value>org/hisp/dhis/sms/outbound/OutboundSms.hbm.xml</value>
+      </list>
+    </property>
+  <property name="hibernateProperties">
+    <props>
+    <prop key="hibernate.dialect">org.hibernate.dialect.H2Dialect</prop>
+    <prop key="hibernate.hbm2ddl.auto">create</prop>
+    </props>
+    </property> 
+  </bean>
+  
+  <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
+    <property name="driverClass" value="org.h2.Driver"/>
+    <property name="jdbcUrl" value="jdbc:h2:mem:inf5750;DB_CLOSE_ON_EXIT=FALSE"/>
+  <property name="user" value="sa"/>
+  <property name="password" value=""/>
+  </bean>
+  
+</beans>
\ No newline at end of file

=== modified file 'dhis-2/dhis-services/pom.xml'
--- dhis-2/dhis-services/pom.xml	2011-12-06 17:41:41 +0000
+++ dhis-2/dhis-services/pom.xml	2011-12-15 20:51:45 +0000
@@ -26,6 +26,7 @@
     <module>dhis-service-aggregationengine-default</module>
     <module>dhis-service-patient</module>
     <module>dhis-service-mobile</module>
+    <module>dhis-service-sms</module>
   </modules>
   
   <dependencies>

=== modified file 'dhis-2/dhis-web/dhis-web-api/pom.xml'
--- dhis-2/dhis-web/dhis-web-api/pom.xml	2011-12-03 17:24:32 +0000
+++ dhis-2/dhis-web/dhis-web-api/pom.xml	2011-12-15 08:46:42 +0000
@@ -47,6 +47,10 @@
       <artifactId>dhis-service-mapgeneration</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.hisp.dhis</groupId>
+      <artifactId>dhis-service-sms</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-webmvc</artifactId>
     </dependency>

=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SmsConfigurationController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SmsConfigurationController.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SmsConfigurationController.java	2011-12-15 20:41:45 +0000
@@ -0,0 +1,71 @@
+package org.hisp.dhis.api.controller;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.sms.SmsConfigurationManager;
+import org.hisp.dhis.sms.config.SmsConfiguration;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+@Controller
+@RequestMapping( value = SmsConfigurationController.RESOURCE_PATH )
+public class SmsConfigurationController
+{
+
+    public static final String RESOURCE_PATH = "/config/sms";
+
+    private static final Log log = LogFactory.getLog( SmsConfigurationController.class );
+
+    @Autowired
+    private SmsConfigurationManager smsConfigurationManager;
+    
+    @RequestMapping( method = RequestMethod.GET )
+    public String getSmsConfiguration( Model model )
+    {
+
+        SmsConfiguration smsConfiguration = smsConfigurationManager.getSmsConfiguration();
+
+        if (smsConfiguration == null) {
+            smsConfiguration = new SmsConfiguration();
+        }
+        
+        model.addAttribute( "model", smsConfiguration );
+
+        return "smsConfiguration";
+    }
+
+    //-------------------------------------------------------------------------------------------------------
+    // POST
+    //-------------------------------------------------------------------------------------------------------
+
+    @RequestMapping( method = RequestMethod.PUT )
+    public String putSmsConfig( @RequestBody SmsConfiguration smsConfiguration, Model model  ) throws Exception
+    {
+        if ( smsConfiguration == null )
+        {
+            throw new  IllegalArgumentException();
+        }
+
+        smsConfigurationManager.updateSmsConfiguration( smsConfiguration );
+        return getSmsConfiguration( model );
+    }
+
+
+    @ExceptionHandler
+    public void mapException(IllegalArgumentException exception, HttpServletResponse response ) throws IOException
+    {
+        log.info( "Exception", exception );
+        response.setStatus( HttpServletResponse.SC_CONFLICT );
+        response.setContentType( "text/plain" );
+        response.getWriter().write( exception.getMessage() );
+    }
+}

=== added directory 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/config'
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/config/sms.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/config/sms.xsl	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/config/sms.xsl	2011-12-15 08:46:42 +0000
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0" xmlns="http://www.w3.org/1999/xhtml";
+  xmlns:d="http://dhis2.org/schema/dxf/2.0";>
+
+  <xsl:template match="d:smsConfiguration">
+    <div class="config">
+      <h2>Sms configuration</h2>
+
+      <table border="1">
+        <tr>
+          <td>Enabled</td>
+          <td>
+            <xsl:value-of select="d:enabled" />
+          </td>
+        </tr>
+        <tr>
+          <td>Polling interval</td>
+          <td>
+            <xsl:value-of select="d:pollingInterval" />
+          </td>
+        </tr>
+        <tr>
+          <td>Long number</td>
+          <td>
+            <xsl:value-of select="d:longNumber" />
+          </td>
+        </tr>
+      </table>
+
+      <h3>Gateways configured</h3>
+      <xsl:if test="d:gateways">
+        <xsl:for-each select="d:gateways/*">
+          <h4>
+            <xsl:value-of select="local-name(.)" />
+          </h4>
+          <table border="1">
+            <xsl:for-each select="child::*">
+              <tr>
+                <td>
+                  <xsl:value-of select="local-name(.)" />
+                </td>
+                <td>
+                  <xsl:value-of select="." />
+                </td>
+              </tr>
+            </xsl:for-each>
+          </table>
+        </xsl:for-each>
+      </xsl:if>
+    </div>
+  </xsl:template>
+
+
+</xsl:stylesheet>

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl	2011-12-15 12:26:12 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl	2011-12-15 20:52:31 +0000
@@ -42,4 +42,8 @@
     <xsl:include href="user.xsl"/>
     <xsl:include href="grid.xsl"/>
 
+    <!-- Config elements -->    
+
+    <xsl:include href="config/sms.xsl"/>
+
 </xsl:stylesheet>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/pom.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/pom.xml	2011-12-03 10:15:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/pom.xml	2011-12-15 08:46:42 +0000
@@ -29,6 +29,10 @@
       <groupId>org.hisp.dhis</groupId>
       <artifactId>dhis-service-mobile</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.hisp.dhis</groupId>
+      <artifactId>dhis-service-sms</artifactId>
+    </dependency>
   </dependencies>
 
   <properties>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/SendSMSAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/SendSMSAction.java	2011-12-10 12:23:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/SendSMSAction.java	2011-12-15 08:46:42 +0000
@@ -28,11 +28,12 @@
  */
 
 
+import org.hisp.dhis.sms.SmsServiceException;
+import org.hisp.dhis.sms.outbound.OutboundSms;
+import org.hisp.dhis.sms.outbound.OutboundSmsService;
 import org.springframework.beans.factory.annotation.Autowired;
 
 import com.opensymphony.xwork2.Action;
-import org.hisp.dhis.api.sms.OutboundSmsService;
-import org.hisp.dhis.api.sms.SmsServiceException;
 
 public class SendSMSAction
     implements Action
@@ -42,7 +43,6 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
-    @Autowired(required=false)
     private OutboundSmsService outboundSmsService;
 
     public void setOutboundSmsService( OutboundSmsService outboundSmsService )
@@ -64,7 +64,7 @@
     
     public boolean getSmsServiceStatus()
     {
-        return outboundSmsService != null && outboundSmsService.isSmsServiceAvailable();
+        return outboundSmsService.isEnabled();
     }
 
     String recipient;
@@ -97,7 +97,7 @@
         {
             try
             {
-                outboundSmsService.sendMessage( msg, recipient );
+                outboundSmsService.sendMessage( new OutboundSms( msg, recipient ) );
                 this.message = "Sent message to " + recipient;
             }
             catch ( SmsServiceException e )

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowMobileConfigurationFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowMobileConfigurationFormAction.java	2011-11-08 08:30:03 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowMobileConfigurationFormAction.java	2011-12-15 08:46:42 +0000
@@ -27,8 +27,8 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import org.hisp.dhis.api.sms.SmsConfig;
-import org.hisp.dhis.api.sms.SmsService;
+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;
@@ -39,36 +39,30 @@
 	// Dependencies
 	// -------------------------------------------------------------------------
 
-	@Autowired(required = false)
-	private SmsService smsService;
+	@Autowired
+        private SmsConfigurationManager smsConfigurationManager;
 
 	// -------------------------------------------------------------------------
 	// Output
 	// -------------------------------------------------------------------------
 
-	private SmsConfig smsConfig;
+	private SmsConfiguration smsConfig;
 
 	@Override
 	public String execute() throws Exception {
-		if (this.smsService != null) {
-			this.smsConfig = this.smsService.getConfig();
-		}
+	    smsConfig = smsConfigurationManager.getSmsConfiguration();
 		return SUCCESS;
 	}
 
 	public boolean getSmsServiceStatus() {
-		return this.smsService != null;
-	}
-
-	public void setSmsService(SmsService smsService) {
-		this.smsService = smsService;
-	}
-
-	public SmsConfig getSmsConfig() {
+		return this.smsConfig != null && this.smsConfig.isEnabled();
+	}
+
+	public SmsConfiguration getSmsConfig() {
 		return smsConfig;
 	}
 
-	public void setSmsConfig(SmsConfig smsConfig) {
+	public void setSmsConfig(SmsConfiguration smsConfig) {
 		this.smsConfig = smsConfig;
 	}
 }

=== 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	2011-12-03 10:15:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml	2011-12-15 08:46:42 +0000
@@ -6,7 +6,9 @@
   <bean id="org.hisp.dhis.mobile.action.MobileHomePageAction" class="org.hisp.dhis.mobile.action.MobileHomePageAction"
     scope="prototype" />
 
-  <bean id="org.hisp.dhis.mobile.action.SendSMSAction" class="org.hisp.dhis.mobile.action.SendSMSAction" scope="prototype" />
+  <bean id="org.hisp.dhis.mobile.action.SendSMSAction" class="org.hisp.dhis.mobile.action.SendSMSAction" scope="prototype">
+    <property name="outboundSmsService" ref="org.hisp.dhis.sms.outbound.OutboundSmsService" />
+  </bean>
 
  <!-- Patient Mobile Settings -->
 

=== modified file 'dhis-2/pom.xml'
--- dhis-2/pom.xml	2011-12-06 22:23:13 +0000
+++ dhis-2/pom.xml	2011-12-15 20:51:45 +0000
@@ -233,6 +233,11 @@
       </dependency>
       <dependency>
         <groupId>org.hisp.dhis</groupId>
+        <artifactId>dhis-service-sms</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.hisp.dhis</groupId>
         <artifactId>dhis-service-mapgeneration</artifactId>
         <version>${project.version}</version>
       </dependency>