← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21667: Merge from dhis2-sms branch / Zubair. Introduces sms/gateways and sms/services in Web API.

 

Merge authors:
  Lars Helge Øverland (larshelge)
  Zubair (rajazubair-asghar)
------------------------------------------------------------
revno: 21667 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2016-01-08 16:07:47 +0100
message:
  Merge from dhis2-sms branch / Zubair. Introduces sms/gateways and sms/services in Web API.
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/GatewayAdministratonService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/config/DefaultGatewayAdministrationService.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/sms/SmsGatewayController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/sms/SmsServiceController.java
modified:
  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/GenericHttpGatewayConfig.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/SMPPGatewayConfig.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/incoming/IncomingSms.java
  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/OutboundSmsTransportService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/SmsPublisher.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/listener/TrackedEntityRegistrationSMSListener.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/outbound/DefaultOutboundSmsTransportService.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/sms/SmsController.java


--
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/sms/config/BulkSmsGatewayConfig.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/BulkSmsGatewayConfig.java	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/BulkSmsGatewayConfig.java	2016-01-04 14:50:32 +0000
@@ -1,5 +1,7 @@
 package org.hisp.dhis.sms.config;
 
+import com.fasterxml.jackson.annotation.JsonProperty;
+
 /*
  * Copyright (c) 2004-2016, University of Oslo
  * All rights reserved.
@@ -39,6 +41,7 @@
 
     private String region;
 
+    @JsonProperty( value = "username" )
     public String getUsername()
     {
         return username;
@@ -49,6 +52,13 @@
         this.username = username;
     }
 
+    @JsonProperty( value = "name" )
+    public String getName()
+    {
+        return super.getName();
+    }
+
+    @JsonProperty( value = "password" )
     public String getPassword()
     {
         return password;
@@ -59,11 +69,18 @@
         this.password = password;
     }
 
+    @JsonProperty( value = "region" )
     public String getRegion()
     {
         return region;
     }
 
+    @JsonProperty( value = "default" )
+    public boolean getStatus()
+    {
+        return super.isDefault();
+    }
+
     public void setRegion( String region )
     {
         this.region = region;

=== modified 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	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/ClickatellGatewayConfig.java	2016-01-04 14:50:32 +0000
@@ -1,5 +1,7 @@
 package org.hisp.dhis.sms.config;
 
+import com.fasterxml.jackson.annotation.JsonProperty;
+
 /*
  * Copyright (c) 2004-2016, University of Oslo
  * All rights reserved.
@@ -39,6 +41,7 @@
 
     private String apiId;
 
+    @JsonProperty( value = "username" )
     public String getUsername()
     {
         return username;
@@ -49,21 +52,35 @@
         this.username = username;
     }
 
+    @JsonProperty( value = "password" )
     public String getPassword()
     {
         return password;
     }
 
+    @JsonProperty( value = "default" )
+    public boolean getStatus()
+    {
+        return super.isDefault();
+    }
+
     public void setPassword( String password )
     {
         this.password = password;
     }
 
+    @JsonProperty( value = "apiid" )
     public String getApiId()
     {
         return apiId;
     }
 
+    @JsonProperty( value = "name" )
+    public String getName()
+    {
+        return super.getName();
+    }
+
     public void setApiId( String apiId )
     {
         this.apiId = apiId;

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/GatewayAdministratonService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/GatewayAdministratonService.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/GatewayAdministratonService.java	2016-01-07 15:15:30 +0000
@@ -0,0 +1,47 @@
+
+/*
+ * Copyright (c) 2004-2015, 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.
+ */
+package org.hisp.dhis.sms.config;
+
+/**
+ * @author Zubair <rajazubair.asghar@xxxxxxxxx>
+ *
+ */
+public interface GatewayAdministratonService
+{
+    String setDefault( String uid );
+
+    boolean removeGateway( String uid );
+
+    SmsConfiguration listGateways();
+
+    SmsGatewayConfig getGatewayConfiguration( String uid );
+
+    String addOrUpdateGateway( SmsGatewayConfig config, Class<?> klass );
+
+}

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/GenericHttpGatewayConfig.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/GenericHttpGatewayConfig.java	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/GenericHttpGatewayConfig.java	2016-01-04 14:50:32 +0000
@@ -34,6 +34,8 @@
 
 import org.hisp.dhis.common.adapter.ParametersMapXmlAdapter;
 
+import com.fasterxml.jackson.annotation.JsonProperty;
+
 public class GenericHttpGatewayConfig
     extends SmsGatewayConfig
 {
@@ -53,16 +55,30 @@
         this.parameters = parameters;
     }
 
+    @JsonProperty( value = "name" )
+    public String getName()
+    {
+        return super.getName();
+    }
+
+    @JsonProperty( value = "urltemplate" )
     public String getUrlTemplate()
     {
         return urlTemplate;
     }
 
+    @JsonProperty( value = "default" )
+    public boolean getStatus()
+    {
+        return super.isDefault();
+    }
+
     public void setUrlTemplate( String urlTemplate )
     {
         this.urlTemplate = urlTemplate;
     }
 
+    @JsonProperty( value = "parameters" )
     @XmlJavaTypeAdapter( ParametersMapXmlAdapter.class )
     public Map<String, String> getParameters()
     {

=== modified 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	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/ModemGatewayConfig.java	2016-01-04 14:50:32 +0000
@@ -1,5 +1,7 @@
 package org.hisp.dhis.sms.config;
 
+import com.fasterxml.jackson.annotation.JsonProperty;
+
 /*
  * Copyright (c) 2004-2016, University of Oslo
  * All rights reserved.
@@ -51,6 +53,7 @@
 
     private boolean outbound;
 
+    @JsonProperty( value = "port" )
     public String getPort()
     {
         return port;
@@ -61,16 +64,30 @@
         this.port = port;
     }
 
+    @JsonProperty( value = "name" )
+    public String getName()
+    {
+        return super.getName();
+    }
+
+    @JsonProperty( value = "baudrate" )
     public int getBaudRate()
     {
         return baudRate;
     }
 
+    @JsonProperty( value = "default" )
+    public boolean getStatus()
+    {
+        return super.isDefault();
+    }
+
     public void setBaudRate( int baudRate )
     {
         this.baudRate = baudRate;
     }
 
+    @JsonProperty( value = "manufacturer" )
     public String getManufacturer()
     {
         return manufacturer;
@@ -81,6 +98,7 @@
         this.manufacturer = manufacturer;
     }
 
+    @JsonProperty( value = "model" )
     public String getModel()
     {
         return model;
@@ -91,6 +109,7 @@
         this.model = model;
     }
 
+    @JsonProperty( value = "pin" )
     public String getPin()
     {
         return pin;
@@ -123,6 +142,7 @@
         this.outbound = outbound;
     }
 
+    @JsonProperty( value = "getsimmemlocation" )
     public String getSimMemLocation()
     {
         return simMemLocation;
@@ -133,6 +153,7 @@
         this.simMemLocation = simMemLocation;
     }
 
+    @JsonProperty( value = "poolinterval" )
     public Integer getPollingInterval()
     {
         return pollingInterval;

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SMPPGatewayConfig.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SMPPGatewayConfig.java	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SMPPGatewayConfig.java	2016-01-04 14:50:32 +0000
@@ -1,5 +1,7 @@
 package org.hisp.dhis.sms.config;
 
+import com.fasterxml.jackson.annotation.JsonProperty;
+
 /*
  * Copyright (c) 2004-2016, University of Oslo
  * All rights reserved.
@@ -41,6 +43,7 @@
 
     private String password;
 
+    @JsonProperty( value = "username" )
     public String getUsername()
     {
         return username;
@@ -51,6 +54,19 @@
         this.username = username;
     }
 
+    @JsonProperty( value = "name" )
+    public String getName()
+    {
+        return super.getName();
+    }
+
+    @JsonProperty( value = "default" )
+    public boolean getStatus()
+    {
+        return super.isDefault();
+    }
+
+    @JsonProperty( value = "password" )
     public String getPassword()
     {
         return password;
@@ -73,6 +89,7 @@
         return true;
     }
 
+    @JsonProperty( value = "port" )
     public int getPort()
     {
         return port;
@@ -83,6 +100,7 @@
         this.port = port;
     }
 
+    @JsonProperty( value = "address" )
     public String getAddress()
     {
         return address;

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfiguration.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfiguration.java	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfiguration.java	2016-01-04 14:50:32 +0000
@@ -34,12 +34,15 @@
 
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlElements;
-import javax.xml.bind.annotation.XmlRootElement;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
 
 /**
  * Serializable configuration object for Sms.
  */
+
 @XmlRootElement( name = "smsConfiguration" )
 public class SmsConfiguration
     implements Serializable
@@ -93,6 +96,7 @@
         this.longNumber = longNumber;
     }
 
+    @JsonProperty( value = "gateways" )
     @XmlElementWrapper( name = "gateways" )
     @XmlElements( { @XmlElement( name = "bulksms", type = BulkSmsGatewayConfig.class ),
         @XmlElement( name = "clickatell", type = ClickatellGatewayConfig.class ),

=== modified 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	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsGatewayConfig.java	2016-01-07 15:15:30 +0000
@@ -30,13 +30,21 @@
 
 import java.io.Serializable;
 
+import org.hisp.dhis.common.DxfNamespaces;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+
 /**
  * Super class for gateway configurations
  */
 @SuppressWarnings( "serial" )
+@JacksonXmlRootElement( localName = "smsgatewayconfig", namespace = DxfNamespaces.DXF_2_0 )
 public abstract class SmsGatewayConfig
     implements Serializable
 {
+    private String uid;
+
     private String name;
 
     private boolean isDefault;
@@ -61,6 +69,17 @@
         this.isDefault = isDefault;
     }
 
+    @JsonProperty( value = "uid" )
+    public String getUid()
+    {
+        return uid;
+    }
+
+    public void setUid( String uid )
+    {
+        this.uid = uid;
+    }
+
     public abstract boolean isInbound();
 
     public abstract boolean isOutbound();

=== modified 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	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/incoming/IncomingSms.java	2016-01-07 15:15:30 +0000
@@ -31,6 +31,11 @@
 import java.io.Serializable;
 import java.util.Date;
 
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+
+@JacksonXmlRootElement( localName = "inboundsms" )
 public class IncomingSms
     implements Serializable
 {
@@ -84,6 +89,8 @@
         this.id = id;
     }
 
+    @JsonProperty( value = "smsencoding", defaultValue = "1" )
+    @JacksonXmlProperty( localName = "smsencoding" )
     public SmsMessageEncoding getEncoding()
     {
         return encoding;
@@ -94,6 +101,8 @@
         this.encoding = encoding;
     }
 
+    @JsonProperty( value = "sentdate" )
+    @JacksonXmlProperty( localName = "sentdate" )
     public Date getSentDate()
     {
         return sentDate;
@@ -104,6 +113,8 @@
         this.sentDate = sentDate;
     }
 
+    @JsonProperty( value = "receiveddate" )
+    @JacksonXmlProperty( localName = "receiveddate" )
     public Date getReceivedDate()
     {
         return receivedDate;
@@ -114,6 +125,8 @@
         this.receivedDate = receivedDate;
     }
 
+    @JsonProperty( value = "originator" )
+    @JacksonXmlProperty( localName = "originator" )
     public String getOriginator()
     {
         return originator;
@@ -124,6 +137,8 @@
         this.originator = originator;
     }
 
+    @JsonProperty( value = "gatewayid", defaultValue = "unknown" )
+    @JacksonXmlProperty( localName = "gatewayid" )
     public String getGatewayId()
     {
         return gatewayId;
@@ -134,6 +149,8 @@
         this.gatewayId = gatewayId;
     }
 
+    @JsonProperty( value = "text" )
+    @JacksonXmlProperty( localName = "text" )
     public String getText()
     {
         return text;
@@ -162,6 +179,8 @@
         this.bytes = bytes;
     }
 
+    @JsonProperty( value = "smsstatus", defaultValue = "1" )
+    @JacksonXmlProperty( localName = "smsstatus" )
     public SmsMessageStatus getStatus()
     {
         return status;

=== modified 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	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSms.java	2016-01-04 14:50:32 +0000
@@ -35,6 +35,11 @@
 
 import org.hisp.dhis.common.BaseIdentifiableObject;
 
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+
+@JacksonXmlRootElement( localName = "outboundsms" )
 public class OutboundSms
     extends BaseIdentifiableObject
 {
@@ -61,6 +66,8 @@
         Collections.addAll( this.recipients, recipients );
     }
 
+    @JsonProperty( value = "recipients" )
+    @JacksonXmlProperty( localName = "recipients" )
     public Set<String> getRecipients()
     {
         return recipients;
@@ -81,6 +88,8 @@
         this.date = date;
     }
 
+    @JsonProperty( value = "message" )
+    @JacksonXmlProperty( localName = "message" )
     public String getMessage()
     {
         return message;

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsTransportService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsTransportService.java	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsTransportService.java	2016-01-07 15:15:30 +0000
@@ -44,6 +44,8 @@
 {
     Map<String, String> getGatewayMap();
 
+    void updateGatewayMap( String key );
+
     void stopService();
 
     void startService();

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/SmsPublisher.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/SmsPublisher.java	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/SmsPublisher.java	2016-01-04 14:50:32 +0000
@@ -1,5 +1,7 @@
 package org.hisp.dhis.sms;
 
+import java.util.concurrent.ScheduledFuture;
+
 /*
  * Copyright (c) 2004-2016, University of Oslo
  * All rights reserved.
@@ -31,6 +33,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.TaskScheduler;
 
 public class SmsPublisher
 {
@@ -42,40 +45,29 @@
     @Autowired
     private SmsConsumerThread smsConsumer;
 
-    private Thread thread;
+    @Autowired
+    private TaskScheduler taskScheduler;
 
-    private boolean stop = false;
+    private ScheduledFuture<?> future;
 
     public void start()
     {
         messageQueue.initialize();
 
-        thread = new Thread()
+        future = taskScheduler.scheduleWithFixedDelay( new Runnable()
         {
             public void run()
             {
-                while ( !stop )
-                {
-                    smsConsumer.spawnSmsConsumer();
-                    
-                    try
-                    {
-                        Thread.sleep( 1000 );
-                    }
-                    catch ( Exception e )
-                    {
-                    }
-                }
+                smsConsumer.spawnSmsConsumer();
             }
-        };
-
-        thread.start();
+        }, 5000 );
 
         log.info( "SMS Consumer Started" );
     }
 
     public void stop()
     {
-        this.stop = true;
+        future.cancel( true );
+        log.info( "SMS Consumer Stopped" );
     }
 }

=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/config/DefaultGatewayAdministrationService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/config/DefaultGatewayAdministrationService.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/config/DefaultGatewayAdministrationService.java	2016-01-07 15:15:30 +0000
@@ -0,0 +1,197 @@
+
+/*
+ * Copyright (c) 2004-2015, 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.
+ */
+package org.hisp.dhis.sms.config;
+
+import java.util.List;
+
+import org.hisp.dhis.common.CodeGenerator;
+import org.hisp.dhis.sms.outbound.OutboundSmsTransportService;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * @author Zubair <rajazubair.asghar@xxxxxxxxx>
+ *
+ */
+public class DefaultGatewayAdministrationService
+    implements GatewayAdministratonService
+{
+
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    @Autowired
+    private SmsConfigurationManager smsConfigMgr;
+
+    @Autowired
+    private OutboundSmsTransportService transportService;
+
+    @Override
+    public SmsConfiguration listGateways()
+    {
+        SmsConfiguration smsConfig = getSmsConfiguration();
+
+        return smsConfig == null ? null : smsConfig;
+    }
+
+    @Override
+    public String setDefault( String uid )
+    {
+        SmsConfiguration smsConfig = getSmsConfiguration();
+
+        List<SmsGatewayConfig> list = smsConfig.getGateways();
+
+        String gatewayName = null;
+
+        if ( !checkGateway( list, uid ) )
+        {
+            return null;
+        }
+        for ( SmsGatewayConfig gateway : list )
+        {
+
+            if ( gateway.getUid().equals( uid ) )
+            {
+                gateway.setDefault( true );
+
+                gatewayName = gateway.getName();
+            }
+            else
+            {
+                gateway.setDefault( false );
+            }
+        }
+
+        return gatewayName;
+    }
+
+    @Override
+    public String addOrUpdateGateway( SmsGatewayConfig payLoad, Class<?> klass )
+    {
+        SmsConfiguration smsConfig = getSmsConfiguration();
+
+        boolean updated = false;
+
+        if ( smsConfig != null )
+        {
+
+            SmsGatewayConfig gatewayConfig = smsConfigMgr.checkInstanceOfGateway( klass );
+
+            int index = -1;
+
+            if ( gatewayConfig != null )
+            {
+                index = smsConfig.getGateways().indexOf( gatewayConfig );
+
+                updated = true;
+            }
+
+            payLoad.setUid( CodeGenerator.generateCode( 10 ) );
+            gatewayConfig = payLoad;
+
+            if ( smsConfig.getGateways() == null || smsConfig.getGateways().isEmpty() )
+            {
+                gatewayConfig.setDefault( true );
+            }
+
+            if ( index >= 0 )
+            {
+                smsConfig.getGateways().set( index, gatewayConfig );
+            }
+            else
+            {
+                smsConfig.getGateways().add( gatewayConfig );
+            }
+
+            smsConfigMgr.updateSmsConfiguration( smsConfig );
+
+            return updated ? "Gateway updated successfully" : "Gateway added successfully";
+        }
+
+        return "No sms configuration found";
+    }
+
+    @Override
+    public boolean removeGateway( String uid )
+    {
+        SmsConfiguration smsConfig = getSmsConfiguration();
+
+        List<SmsGatewayConfig> list = smsConfig.getGateways();
+
+        for ( SmsGatewayConfig gateway : list )
+        {
+            if ( gateway.getUid().equals( uid ) )
+            {
+                smsConfig.getGateways().remove( gateway );
+
+                transportService.updateGatewayMap( gateway.getClass().getTypeName() );
+
+                smsConfigMgr.updateSmsConfiguration( smsConfig );
+
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    @Override
+    public SmsGatewayConfig getGatewayConfiguration( String uid )
+    {
+        SmsConfiguration smsConfig = getSmsConfiguration();
+        List<SmsGatewayConfig> list = smsConfig.getGateways();
+        for ( SmsGatewayConfig gw : list )
+        {
+            if ( gw.getUid().equals( uid ) )
+            {
+                return gw;
+            }
+        }
+
+        return null;
+    }
+
+    private boolean checkGateway( List<SmsGatewayConfig> list, String uid )
+    {
+        for ( SmsGatewayConfig gateway : list )
+        {
+            if ( gateway.getUid().equals( uid ) )
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    private SmsConfiguration getSmsConfiguration()
+    {
+        return smsConfigMgr.getSmsConfiguration();
+    }
+}

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/listener/TrackedEntityRegistrationSMSListener.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/listener/TrackedEntityRegistrationSMSListener.java	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/listener/TrackedEntityRegistrationSMSListener.java	2016-01-04 14:50:32 +0000
@@ -149,7 +149,7 @@
         programInstanceService.enrollTrackedEntityInstance(
             trackedEntityInstanceService.getTrackedEntityInstance( trackedEntityInstanceId ), smsCommand.getProgram(),
             new Date(), date, orgUnit );
-        smsSender.sendMessage( "Register new User successfully", senderPhoneNumber );
+        smsSender.sendMessage( "New User successfully Registered", senderPhoneNumber );
 
     }
 

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/outbound/DefaultOutboundSmsTransportService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/outbound/DefaultOutboundSmsTransportService.java	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/outbound/DefaultOutboundSmsTransportService.java	2016-01-07 15:15:30 +0000
@@ -41,6 +41,7 @@
 import org.hisp.dhis.sms.config.ClickatellGatewayConfig;
 import org.hisp.dhis.sms.config.GateWayFactory;
 import org.hisp.dhis.sms.config.GenericHttpGatewayConfig;
+import org.hisp.dhis.sms.config.ModemGatewayConfig;
 import org.hisp.dhis.sms.config.SMPPGatewayConfig;
 import org.hisp.dhis.sms.config.SMSGatewayStatus;
 import org.hisp.dhis.sms.config.SmsConfiguration;
@@ -62,16 +63,6 @@
 {
     private static final Log log = LogFactory.getLog( DefaultOutboundSmsTransportService.class );
 
-    private static final String BULK_GATEWAY = "bulk_gw";
-
-    private static final String CLICKATELL_GATEWAY = "clickatell_gw";
-
-    private static final String HTTP_GATEWAY = "generic_http_gw";
-
-    private static final String MODEM_GATEWAY = "modem_gw";
-
-    private static final String SMPP_GATEWAY = "smpp_gw";
-
     public static final Map<String, String> GATEWAY_MAP = new HashMap<>();
 
     private SmsConfiguration config;
@@ -102,7 +93,7 @@
     {
         this.smsPublisher = smsPublisher;
     }
-    
+
     // -------------------------------------------------------------------------
     // OutboundSmsTransportService implementation
     // -------------------------------------------------------------------------
@@ -118,6 +109,11 @@
         return GATEWAY_MAP;
     }
 
+    public void updateGatewayMap( String key )
+    {
+        GATEWAY_MAP.remove( key );
+    }
+
     @Override
     public void stopService()
     {
@@ -155,7 +151,7 @@
             try
             {
                 getService().startService();
-                if ( GATEWAY_MAP.containsKey( SMPP_GATEWAY ) )
+                if ( GATEWAY_MAP.containsKey( SMPPGatewayConfig.class.getTypeName() ) )
                 {
                     getService().setInboundMessageNotification( smppInboundMessageNotification );
                 }
@@ -230,23 +226,23 @@
 
                     if ( gatewayConfig instanceof BulkSmsGatewayConfig )
                     {
-                        GATEWAY_MAP.put( BULK_GATEWAY, gateway.getGatewayId() );
+                        GATEWAY_MAP.put( BulkSmsGatewayConfig.class.getTypeName(), gateway.getGatewayId() );
                     }
                     else if ( gatewayConfig instanceof ClickatellGatewayConfig )
                     {
-                        GATEWAY_MAP.put( CLICKATELL_GATEWAY, gateway.getGatewayId() );
+                        GATEWAY_MAP.put( ClickatellGatewayConfig.class.getTypeName(), gateway.getGatewayId() );
                     }
                     else if ( gatewayConfig instanceof GenericHttpGatewayConfig )
                     {
-                        GATEWAY_MAP.put( HTTP_GATEWAY, gateway.getGatewayId() );
+                        GATEWAY_MAP.put( GenericHttpGatewayConfig.class.getTypeName(), gateway.getGatewayId() );
                     }
                     else if ( gatewayConfig instanceof SMPPGatewayConfig )
                     {
-                        GATEWAY_MAP.put( SMPP_GATEWAY, gateway.getGatewayId() );
+                        GATEWAY_MAP.put( SMPPGatewayConfig.class.getTypeName(), gateway.getGatewayId() );
                     }
                     else
                     {
-                        GATEWAY_MAP.put( MODEM_GATEWAY, gateway.getGatewayId() );
+                        GATEWAY_MAP.put( ModemGatewayConfig.class.getTypeName(), gateway.getGatewayId() );
                     }
 
                     log.debug( "Added gateway " + gatewayConfig.getName() );
@@ -314,23 +310,23 @@
 
         if ( gatewayConfig instanceof BulkSmsGatewayConfig )
         {
-            gatewayId = GATEWAY_MAP.get( BULK_GATEWAY );
+            gatewayId = GATEWAY_MAP.get( BulkSmsGatewayConfig.class.getTypeName() );
         }
         else if ( gatewayConfig instanceof ClickatellGatewayConfig )
         {
-            gatewayId = GATEWAY_MAP.get( CLICKATELL_GATEWAY );
+            gatewayId = GATEWAY_MAP.get( ClickatellGatewayConfig.class.getTypeName() );
         }
         else if ( gatewayConfig instanceof GenericHttpGatewayConfig )
         {
-            gatewayId = GATEWAY_MAP.get( HTTP_GATEWAY );
+            gatewayId = GATEWAY_MAP.get( GenericHttpGatewayConfig.class.getTypeName() );
         }
         else if ( gatewayConfig instanceof SMPPGatewayConfig )
         {
-            gatewayId = GATEWAY_MAP.get( SMPP_GATEWAY );
+            gatewayId = GATEWAY_MAP.get( SMPPGatewayConfig.class.getTypeName() );
         }
         else
         {
-            gatewayId = GATEWAY_MAP.get( MODEM_GATEWAY );
+            gatewayId = GATEWAY_MAP.get( ModemGatewayConfig.class.getTypeName() );
         }
 
         return gatewayId;

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2016-01-06 19:24:34 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2016-01-07 15:16:38 +0000
@@ -1125,7 +1125,10 @@
   <bean id="org.hisp.dhis.sms.task.SendSmsTask" class="org.hisp.dhis.sms.task.SendSmsTask" scope="prototype" />
   
   <bean id="org.hisp.dhis.sms.SmsConsumerThread" class="org.hisp.dhis.sms.SmsConsumerThread" />
-
+  
+  <bean id="org.hisp.dhis.sms.config.GatewayAdministratonService" 
+  			class="org.hisp.dhis.sms.config.DefaultGatewayAdministrationService" />
+  
   <!-- I18nService -->
 
   <bean id="org.hisp.dhis.i18n.I18nService" class="org.hisp.dhis.i18n.DefaultI18nService">

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/sms/SmsController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/sms/SmsController.java	2016-01-08 10:14:46 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/sms/SmsController.java	2016-01-08 15:07:47 +0000
@@ -28,25 +28,30 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.io.IOException;
+
+import java.text.ParseException;
+import java.util.Date;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.hisp.dhis.dxf2.render.RenderService;
 import org.hisp.dhis.dxf2.webmessage.WebMessageException;
 import org.hisp.dhis.sms.SmsSender;
+import org.hisp.dhis.sms.incoming.IncomingSms;
 import org.hisp.dhis.sms.incoming.IncomingSmsService;
+import org.hisp.dhis.sms.outbound.OutboundSms;
 import org.hisp.dhis.webapi.service.WebMessageService;
 import org.hisp.dhis.webapi.utils.WebMessageUtils;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.text.ParseException;
-import java.util.Date;
-import java.util.Map;
-
 /**
  * Zubair <rajazubair.asghar@xxxxxxxxx>
  */
@@ -67,6 +72,9 @@
     @Autowired
     private IncomingSmsService incomingSMSService;
 
+    @Autowired
+    private RenderService renderService;
+
     // -------------------------------------------------------------------------
     // POST
     // -------------------------------------------------------------------------
@@ -75,7 +83,7 @@
     @RequestMapping( value = "/outbound", method = RequestMethod.POST )
     public void sendSMSMessage( @RequestParam String recipient, @RequestParam String message,
         HttpServletResponse response, HttpServletRequest request )
-        throws WebMessageException
+            throws WebMessageException
     {
         if ( recipient == null || recipient.length() <= 0 )
         {
@@ -91,7 +99,7 @@
 
         if ( result.equals( "success" ) )
         {
-            webMessageService.send( WebMessageUtils.ok( "Message Sent" ), response, request );
+            webMessageService.send( WebMessageUtils.ok( "Message sent" ), response, request );
         }
         else
         {
@@ -101,25 +109,20 @@
 
     @PreAuthorize( "hasRole('ALL') or hasRole(' F_MOBILE_SENDSMS')" )
     @RequestMapping( value = "/outbound", method = RequestMethod.POST, consumes = "application/json" )
-    public void sendSMSMessage( @RequestBody Map<String, Object> jsonMessage, HttpServletResponse response,
-        HttpServletRequest request )
-        throws WebMessageException
+    public void sendSMSMessage( HttpServletResponse response, HttpServletRequest request )
+        throws WebMessageException, IOException
     {
-        if ( jsonMessage == null )
-        {
-            throw new WebMessageException( WebMessageUtils.conflict( "Request body must be specified" ) );
-        }
-
-        String result = smsSender.sendMessage( jsonMessage.get( "message" ).toString(),
-            jsonMessage.get( "recipient" ).toString() );
-
+        OutboundSms sms = renderService.fromJson( request.getInputStream(), OutboundSms.class );
+
+        String result = smsSender.sendMessage( sms );
+        
         if ( result.equals( "success" ) )
         {
-            webMessageService.send( WebMessageUtils.ok( "Message Sent" ), response, request );
+            webMessageService.send( WebMessageUtils.ok( "Message sent" ), response, request );
         }
         else
         {
-            throw new WebMessageException( WebMessageUtils.error( "Message seding failed" ) );
+            webMessageService.send( WebMessageUtils.error( "Message sending failed" ), response, request );
         }
     }
 
@@ -127,12 +130,12 @@
     @PreAuthorize( "hasRole('ALL') or hasRole('F_MOBILE_SETTINGS')" )
     public void receiveSMSMessage( @RequestParam String originator, @RequestParam( required = false ) Date receivedTime,
         @RequestParam String message, @RequestParam( defaultValue = "Unknown", required = false ) String gateway,
-        HttpServletRequest request, HttpServletResponse response )
-        throws WebMessageException, ParseException
+        HttpServletRequest request, HttpServletResponse response)
+            throws WebMessageException, ParseException
     {
         if ( originator == null || originator.length() <= 0 )
         {
-            throw new WebMessageException( WebMessageUtils.conflict( "originator must be specified" ) );
+            throw new WebMessageException( WebMessageUtils.conflict( "Originator must be specified" ) );
         }
 
         if ( message == null || message.length() <= 0 )
@@ -142,26 +145,24 @@
 
         int smsId = incomingSMSService.save( message, originator, gateway, receivedTime );
 
-        webMessageService.send( WebMessageUtils.ok( "Received: SMS ID " + smsId ), response, request );
+        webMessageService.send( WebMessageUtils.ok( "Received SMS: " + smsId ), response, request );
 
     }
 
     @RequestMapping( value = "/inbound", method = RequestMethod.POST, consumes = "application/json" )
     @PreAuthorize( "hasRole('ALL') or hasRole('F_MOBILE_SETTINGS')" )
-    public void receiveSMSMessage( @RequestBody Map<String, Object> jsonMassage, HttpServletRequest request,
-        HttpServletResponse response )
-        throws WebMessageException, ParseException
+    public void receiveSMSMessage( HttpServletRequest request, HttpServletResponse response )
+        throws WebMessageException, ParseException, IOException
     {
-        if ( jsonMassage == null )
+        if ( incomingSMSService == null )
         {
-            throw new WebMessageException( WebMessageUtils.conflict( "RequestBody must not be empty" ) );
+            throw new WebMessageException( WebMessageUtils.error( "Service unavailable" ) );
         }
 
-        int smsId = incomingSMSService.save( jsonMassage.get( "message" ).toString(),
-            jsonMassage.get( "originator" ).toString(), jsonMassage.get( "gateway" ).toString(),
-            (Date) jsonMassage.get( "receivedTime" ) );
-
-        webMessageService.send( WebMessageUtils.ok( "Received: SMS ID " + smsId ), response, request );
-
+        IncomingSms sms = renderService.fromJson( request.getInputStream(), IncomingSms.class );
+
+        int smsId = incomingSMSService.save( sms );
+
+        webMessageService.send( WebMessageUtils.ok( "Received SMS:" + smsId ), response, request );
     }
 }

=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/sms/SmsGatewayController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/sms/SmsGatewayController.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/sms/SmsGatewayController.java	2016-01-08 15:07:47 +0000
@@ -0,0 +1,261 @@
+package org.hisp.dhis.webapi.controller.sms;
+
+/*
+ * Copyright (c) 2004-2015, 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 javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.hisp.dhis.dxf2.render.RenderService;
+import org.hisp.dhis.dxf2.webmessage.WebMessageException;
+import org.hisp.dhis.sms.config.BulkSmsGatewayConfig;
+import org.hisp.dhis.sms.config.ClickatellGatewayConfig;
+import org.hisp.dhis.sms.config.GatewayAdministratonService;
+import org.hisp.dhis.sms.config.GenericHttpGatewayConfig;
+import org.hisp.dhis.sms.config.ModemGatewayConfig;
+import org.hisp.dhis.sms.config.SMPPGatewayConfig;
+import org.hisp.dhis.sms.config.SmsGatewayConfig;
+import org.hisp.dhis.sms.outbound.OutboundSmsTransportService;
+import org.hisp.dhis.webapi.service.WebMessageService;
+import org.hisp.dhis.webapi.utils.WebMessageUtils;
+
+import java.io.IOException;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * Zubair <rajazubair.asghar@xxxxxxxxx>
+ */
+
+@RestController
+@RequestMapping( value = "/sms/gateways" )
+public class SmsGatewayController
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    @Autowired
+    private WebMessageService webMessageService;
+
+    @Autowired
+    private OutboundSmsTransportService outboundSmsTransportService;
+
+    @Autowired
+    private RenderService renderService;
+
+    @Autowired
+    private GatewayAdministratonService gatewayAdminService;
+
+    // -------------------------------------------------------------------------
+    // GET
+    // -------------------------------------------------------------------------
+
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_MOBILE_SENDSMS')" )
+    @RequestMapping( method = RequestMethod.GET, produces = { "application/json" } )
+    public void getGateways( HttpServletRequest request, HttpServletResponse response )
+        throws WebMessageException, IOException
+    {
+        if ( gatewayAdminService == null )
+        {
+            throw new WebMessageException( WebMessageUtils.conflict( "Gateway admin service is not available" ) );
+        }
+
+        renderService.toJson( response.getOutputStream(), gatewayAdminService.listGateways() );
+    }
+
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_MOBILE_SENDSMS')" )
+    @RequestMapping( value = "/default", method = RequestMethod.GET )
+    public void getDefault( HttpServletRequest request, HttpServletResponse response )
+        throws WebMessageException
+    {
+        if ( outboundSmsTransportService == null )
+        {
+            throw new WebMessageException( WebMessageUtils.conflict( "Transport service is not available" ) );
+        }
+
+        String defaultGateway = outboundSmsTransportService.getDefaultGateway();
+
+        webMessageService.send( WebMessageUtils.ok( "Default Gateway " + defaultGateway ), response, request );
+    }
+
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_MOBILE_SENDSMS')" )
+    @RequestMapping( value = "/{uid}", method = RequestMethod.GET, produces = "application/json" )
+    public void getClickatellConfiguration( @PathVariable String uid, HttpServletRequest request,
+        HttpServletResponse response )
+            throws WebMessageException, IOException
+    {
+        if ( gatewayAdminService == null )
+        {
+            throw new WebMessageException( WebMessageUtils.conflict( "Gateway admin service is not available" ) );
+        }
+
+        renderService.toJson( response.getOutputStream(), gatewayAdminService.getGatewayConfiguration( uid ) );
+    }
+
+    // -------------------------------------------------------------------------
+    // PUT,POST
+    // -------------------------------------------------------------------------
+
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_MOBILE_SENDSMS')" )
+    @RequestMapping( value = "/clickatell", method = { RequestMethod.POST,
+        RequestMethod.PUT }, produces = "application/json" )
+    public void addOrUpdateClickatellConfiguration( HttpServletRequest request, HttpServletResponse response )
+        throws WebMessageException, IOException
+    {
+        if ( gatewayAdminService == null )
+        {
+            throw new WebMessageException( WebMessageUtils.conflict( "Gateway admin service is not available" ) );
+        }
+
+        SmsGatewayConfig payLoad = renderService.fromJson( request.getInputStream(), ClickatellGatewayConfig.class );
+
+        renderService.toJson( response.getOutputStream(),
+            gatewayAdminService.addOrUpdateGateway( payLoad, ClickatellGatewayConfig.class ) );
+    }
+
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_MOBILE_SENDSMS')" )
+    @RequestMapping( value = "/bulksms", method = { RequestMethod.POST,
+        RequestMethod.PUT }, produces = "application/json" )
+    public void addOrUpdatebulksmsConfiguration( HttpServletRequest request, HttpServletResponse response )
+        throws WebMessageException, IOException
+    {
+        if ( gatewayAdminService == null )
+        {
+            throw new WebMessageException( WebMessageUtils.conflict( "Gateway admin service is not available" ) );
+        }
+
+        BulkSmsGatewayConfig payLoad = renderService.fromJson( request.getInputStream(), BulkSmsGatewayConfig.class );
+
+        renderService.toJson( response.getOutputStream(),
+            gatewayAdminService.addOrUpdateGateway( payLoad, BulkSmsGatewayConfig.class ) );
+    }
+
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_MOBILE_SENDSMS')" )
+    @RequestMapping( value = "/smpp", method = { RequestMethod.POST,
+        RequestMethod.PUT }, produces = "application/json" )
+    public void addOrUpdateSmppConfiguration( HttpServletRequest request, HttpServletResponse response )
+        throws WebMessageException, IOException
+    {
+        if ( gatewayAdminService == null )
+        {
+            throw new WebMessageException( WebMessageUtils.conflict( "Gateway admin service is not available" ) );
+        }
+
+        SMPPGatewayConfig payLoad = renderService.fromJson( request.getInputStream(), SMPPGatewayConfig.class );
+
+        renderService.toJson( response.getOutputStream(),
+            gatewayAdminService.addOrUpdateGateway( payLoad, SMPPGatewayConfig.class ) );
+    }
+
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_MOBILE_SENDSMS')" )
+    @RequestMapping( value = "/generichttp", method = { RequestMethod.POST,
+        RequestMethod.PUT }, produces = "application/json" )
+    public void addOrUpdateGenericConfiguration( HttpServletRequest request, HttpServletResponse response )
+        throws WebMessageException, IOException
+    {
+        if ( gatewayAdminService == null )
+        {
+            throw new WebMessageException( WebMessageUtils.conflict( "Gateway admin service is not available" ) );
+        }
+
+        GenericHttpGatewayConfig payLoad = renderService.fromJson( request.getInputStream(),
+            GenericHttpGatewayConfig.class );
+
+        renderService.toJson( response.getOutputStream(),
+            gatewayAdminService.addOrUpdateGateway( payLoad, GenericHttpGatewayConfig.class ) );
+    }
+
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_MOBILE_SENDSMS')" )
+    @RequestMapping( value = "/modem", method = { RequestMethod.POST,
+        RequestMethod.PUT }, produces = "application/json" )
+    public void addOrUpdateModemConfiguration( HttpServletRequest request, HttpServletResponse response )
+        throws WebMessageException, IOException
+    {
+        if ( gatewayAdminService == null )
+        {
+            throw new WebMessageException( WebMessageUtils.conflict( "Gateway admin service is not available" ) );
+        }
+
+        ModemGatewayConfig payLoad = renderService.fromJson( request.getInputStream(), ModemGatewayConfig.class );
+
+        renderService.toJson( response.getOutputStream(),
+            gatewayAdminService.addOrUpdateGateway( payLoad, ModemGatewayConfig.class ) );
+    }
+
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_MOBILE_SENDSMS')" )
+    @RequestMapping( value = "/default/{uid}", method = RequestMethod.PUT )
+    public void setDefault( @PathVariable String uid, HttpServletRequest request, HttpServletResponse response )
+        throws WebMessageException
+    {
+        if ( gatewayAdminService == null )
+        {
+            throw new WebMessageException( WebMessageUtils.conflict( "Gateway admin service is not available" ) );
+        }
+
+        String gateway = gatewayAdminService.setDefault( uid );
+
+        if ( gateway == null )
+        {
+            webMessageService.send( WebMessageUtils.conflict( "No gateway against this id" ), response, request );
+        }
+        else
+        {
+            webMessageService.send( WebMessageUtils.ok( gateway + " is set to default" ), response, request );
+        }
+    }
+
+    // -------------------------------------------------------------------------
+    // DELETE
+    // -------------------------------------------------------------------------
+
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_MOBILE_SENDSMS')" )
+    @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
+    public void removeGateway( @PathVariable String uid, HttpServletRequest request, HttpServletResponse response )
+        throws WebMessageException
+    {
+        if ( gatewayAdminService == null )
+        {
+            throw new WebMessageException( WebMessageUtils.conflict( "Gateway admin service is not available" ) );
+        }
+
+        if ( gatewayAdminService.removeGateway( uid ) )
+        {
+            webMessageService.send( WebMessageUtils.ok( "Gateway removed successfully" ), response, request );
+        }
+        else
+        {
+            webMessageService.send( WebMessageUtils.conflict( "No gateway against this id" ), response, request );
+        }
+    }
+}

=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/sms/SmsServiceController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/sms/SmsServiceController.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/sms/SmsServiceController.java	2016-01-08 15:07:47 +0000
@@ -0,0 +1,148 @@
+package org.hisp.dhis.webapi.controller.sms;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.hisp.dhis.dxf2.webmessage.WebMessageException;
+import org.hisp.dhis.sms.outbound.OutboundSmsTransportService;
+import org.hisp.dhis.sms.outbound.SMSServiceStatus;
+import org.hisp.dhis.webapi.service.WebMessageService;
+import org.hisp.dhis.webapi.utils.WebMessageUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+/*
+ * Copyright (c) 2004-2015, 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 Zubair <rajazubair.asghar@xxxxxxxxx>
+ *
+ */
+
+@RestController
+@RequestMapping( value = "/sms/services" )
+public class SmsServiceController
+{
+
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    @Autowired
+    private WebMessageService webMessageService;
+
+    @Autowired
+    private OutboundSmsTransportService outboundSmsTransportService;
+
+    // -------------------------------------------------------------------------
+    // GET
+    // -------------------------------------------------------------------------
+
+    @PreAuthorize( "hasRole('ALL') or hasRole(' F_MOBILE_SENDSMS')" )
+    @RequestMapping( method = RequestMethod.GET )
+    public void getSmsServiceStatus( HttpServletRequest request, HttpServletResponse response )
+        throws WebMessageException
+    {
+        if ( outboundSmsTransportService == null )
+        {
+            throw new WebMessageException( WebMessageUtils.error( "Transport service is not available" ) );
+        }
+
+        SMSServiceStatus status = outboundSmsTransportService.getServiceStatusEnum();
+
+        webMessageService.send( WebMessageUtils.ok( status.toString() ), response, request );
+    }
+
+    // -------------------------------------------------------------------------
+    // POST,PUT
+    // -------------------------------------------------------------------------
+
+    @PreAuthorize( "hasRole('ALL') or hasRole(' F_MOBILE_SENDSMS')" )
+    @RequestMapping( method = RequestMethod.POST )
+    public void startSmsService( HttpServletRequest request, HttpServletResponse response )
+        throws WebMessageException
+    {
+        if ( outboundSmsTransportService == null )
+        {
+            throw new WebMessageException( WebMessageUtils.error( "Transport service is not available" ) );
+        }
+
+        SMSServiceStatus status = outboundSmsTransportService.getServiceStatusEnum();
+        if ( status == SMSServiceStatus.STARTED )
+        {
+            throw new WebMessageException( WebMessageUtils.conflict( "Service already started" ) );
+        }
+
+        outboundSmsTransportService.startService();
+
+        webMessageService.send( WebMessageUtils.ok( "Service started" ), response, request );
+    }
+
+    @PreAuthorize( "hasRole('ALL') or hasRole(' F_MOBILE_SENDSMS')" )
+    @RequestMapping( method = RequestMethod.PUT )
+    public void reloadSmsService( HttpServletRequest request, HttpServletResponse response )
+        throws WebMessageException
+    {
+        if ( outboundSmsTransportService == null )
+        {
+            throw new WebMessageException( WebMessageUtils.error( "Transport service is not available" ) );
+        }
+
+        outboundSmsTransportService.reloadConfig();
+
+        webMessageService.send( WebMessageUtils.ok( "Sms configuration reloaded" ), response, request );
+    }
+
+    // -------------------------------------------------------------------------
+    // DELETE
+    // -------------------------------------------------------------------------
+
+    @PreAuthorize( "hasRole('ALL') or hasRole(' F_MOBILE_SENDSMS')" )
+    @RequestMapping( method = RequestMethod.DELETE )
+    public void stopSmsService( HttpServletRequest request, HttpServletResponse response )
+        throws WebMessageException
+    {
+        if ( outboundSmsTransportService == null )
+        {
+            throw new WebMessageException( WebMessageUtils.error( "Transport service is not available" ) );
+        }
+
+        SMSServiceStatus status = outboundSmsTransportService.getServiceStatusEnum();
+        if ( status == SMSServiceStatus.STOPPED )
+        {
+            throw new WebMessageException( WebMessageUtils.conflict( "Service already stopped" ) );
+        }
+
+        outboundSmsTransportService.stopService();
+
+        webMessageService.send( WebMessageUtils.ok( "Service stopped" ), response, request );
+    }
+}