← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8080: update the outbound sms status

 

------------------------------------------------------------
revno: 8080
committer: Long <Long@Long-Laptop>
branch nick: dhis2
timestamp: Fri 2012-09-14 11:57:46 +0700
message:
  update the outbound sms status
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsService.java
  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/outbound/OutboundSmsServiceImpl.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/SmsLibService.java
  dhis-2/dhis-services/dhis-service-sms/src/main/resources/META-INF/dhis/beans.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/sms/outbound/OutboundSmsService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsService.java	2012-08-09 09:50:18 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsService.java	2012-09-14 04:57:46 +0000
@@ -50,6 +50,8 @@
      */
     String sendMessage( OutboundSms sms, String gatewayId )
         throws SmsServiceException;
-    
+
     List<OutboundSms> getAllOutboundSms();
+
+    int save( OutboundSms sms );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/SmsConfigurationManagerImpl.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/SmsConfigurationManagerImpl.java	2012-09-07 10:18:43 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/SmsConfigurationManagerImpl.java	2012-09-14 04:57:46 +0000
@@ -109,7 +109,6 @@
     public void updateSmsConfiguration( SmsConfiguration config )
     {
         systemSettingManager.saveSystemSetting( SystemSettingManager.KEY_SMS_CONFIG, config );
-
         // Reinitialize components relying on sms config.
         initializeSmsConfigurables();
     }

=== modified 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	2012-08-09 09:50:18 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java	2012-09-14 04:57:46 +0000
@@ -118,6 +118,11 @@
         return outboundSmsStore.getAll();
     }
     
+    @Override
+    public int save(OutboundSms sms) {
+        return outboundSmsStore.save( sms );
+    }
+    
     // -------------------------------------------------------------------------
     // Support methods
     // -------------------------------------------------------------------------
@@ -126,13 +131,13 @@
     {
         try
         {
-            sms.setStatus( OutboundSmsStatus.SENT );
             return transportService.sendMessage( sms, id );
         }
         catch ( SmsServiceException e )
         {
             log.debug( "Exception sending message " + sms, e );
             sms.setStatus( OutboundSmsStatus.ERROR );
+            this.save( sms );
             
             return "Exception sending message " + sms + e.getMessage();
         }

=== modified 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	2012-06-04 06:37:01 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/TestOutboundSmsService.java	2012-09-14 04:57:46 +0000
@@ -104,4 +104,11 @@
         // TODO Auto-generated method stub
         return null;
     }
+
+    @Override
+    public int save( OutboundSms sms )
+    {
+        // TODO Auto-generated method stub
+        return 0;
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java	2012-08-30 12:47:05 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java	2012-09-14 04:57:46 +0000
@@ -43,6 +43,8 @@
 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.OutboundSmsStatus;
+import org.hisp.dhis.sms.outbound.OutboundSmsStore;
 import org.hisp.dhis.sms.outbound.OutboundSmsTransportService;
 import org.smslib.AGateway;
 import org.smslib.GatewayException;
@@ -76,13 +78,18 @@
 
     private final String SMPP_GATEWAY = "smpp_gw";
 
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
     private IInboundMessageNotification smppInboundMessageNotification;
 
+    private OutboundSmsStore outboundSmsStore;
+
     // -------------------------------------------------------------------------
     // Implementation methods
     // -------------------------------------------------------------------------
 
-
     @Override
     public boolean isEnabled()
     {
@@ -177,18 +184,23 @@
                 // Make sure we delete tmp. group
                 removeGroup( recipient );
             }
+            sms.setStatus( OutboundSmsStatus.ERROR );
         }
 
         if ( sent )
         {
             message = "success";
+            sms.setStatus( OutboundSmsStatus.SENT );
         }
         else
         {
             log.warn( "Message not sent" );
             message = "message_not_sent";
+            sms.setStatus( OutboundSmsStatus.ERROR );
         }
 
+        this.save( sms );
+
         return message;
     }
 
@@ -282,7 +294,8 @@
                     else if ( gatewayConfig instanceof SMPPGatewayConfig )
                     {
                         gatewayMap.put( SMPP_GATEWAY, gateway.getGatewayId() );
-                 //       Service.getInstance().setInboundMessageNotification( new InboundNotification() );
+                        // Service.getInstance().setInboundMessageNotification(
+                        // new InboundNotification() );
                     }
                     else
                     {
@@ -431,12 +444,16 @@
             log.debug( "Sent message through gateway " + gateway.getGatewayId() + ": " + msg );
         }
     }
-    
+
     public void setSmppInboundMessageNotification( IInboundMessageNotification smppInboundMessageNotification )
     {
         this.smppInboundMessageNotification = smppInboundMessageNotification;
     }
 
+    public void setOutboundSmsStore( OutboundSmsStore outboundSmsStore )
+    {
+        this.outboundSmsStore = outboundSmsStore;
+    }
 
     @Override
     public List<OutboundSms> getAllOutboundSms()
@@ -444,4 +461,10 @@
         // TODO Auto-generated method stub
         return null;
     }
+
+    @Override
+    public int save( OutboundSms sms )
+    {
+        return outboundSmsStore.save( sms );
+    }
 }

=== modified 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	2012-08-30 12:47:05 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/resources/META-INF/dhis/beans.xml	2012-09-14 04:57:46 +0000
@@ -18,6 +18,7 @@
 
   <bean id="smsLibService" class="org.hisp.dhis.sms.smslib.SmsLibService">
     <property name="smppInboundMessageNotification" ref="org.hisp.dhis.sms.incoming.SMPPInboundNotification" />
+	<property name="outboundSmsStore" ref="org.hisp.dhis.sms.outbound.OutboundSmsStore" />
   </bean>
 
   <bean id="org.hisp.dhis.sms.incoming.SMPPInboundNotification" class="org.hisp.dhis.sms.incoming.SMPPInboundNotification">