← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11413: Web sms, removed poor try/catch code

 

------------------------------------------------------------
revno: 11413
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-07-17 08:24:30 +0200
message:
  Web sms, removed poor try/catch code
modified:
  dhis-2/dhis-web/dhis-web-sms/src/main/java/org/hisp/dhis/sms/outcoming/ProcessingSendSMSAction.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-web/dhis-web-sms/src/main/java/org/hisp/dhis/sms/outcoming/ProcessingSendSMSAction.java'
--- dhis-2/dhis-web/dhis-web-sms/src/main/java/org/hisp/dhis/sms/outcoming/ProcessingSendSMSAction.java	2013-07-17 06:16:40 +0000
+++ dhis-2/dhis-web/dhis-web-sms/src/main/java/org/hisp/dhis/sms/outcoming/ProcessingSendSMSAction.java	2013-07-17 06:24:30 +0000
@@ -27,13 +27,10 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.PropertyAccessor;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.opensymphony.xwork2.Action;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.message.MessageSender;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -47,10 +44,11 @@
 import org.hisp.dhis.user.UserGroupService;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import java.io.IOException;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.opensymphony.xwork2.Action;
 
 /**
  * @author Dang Duy Hieu
@@ -155,6 +153,7 @@
 
     @SuppressWarnings("unchecked")
     public String execute()
+        throws Exception
     {
         gatewayId = transportService.getDefaultGateway();
 
@@ -178,31 +177,17 @@
 
         if ( sendTarget != null && sendTarget.equals( "phone" ) )
         {
-            try
-            {
-                ObjectMapper mapper = new ObjectMapper().setVisibility( PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY );
-                mapper.disable( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES );
-                recipients = mapper.readValue( recipients.iterator().next(), Set.class );
+            ObjectMapper mapper = new ObjectMapper().setVisibility( PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY );
+            mapper.disable( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES );
+            recipients = mapper.readValue( recipients.iterator().next(), Set.class );
 
-                for ( String each : recipients )
-                {
-                    User user = new User();
-                    user.setPhoneNumber( each );
-                    recipientsList.add( user );
-                }
-            }
-            catch ( JsonParseException e )
-            {
-                e.printStackTrace();
-            }
-            catch ( JsonMappingException e )
-            {
-                e.printStackTrace();
-            }
-            catch ( IOException e )
-            {
-                e.printStackTrace();
-            }
+            for ( String each : recipients )
+            {
+                User user = new User();
+                user.setPhoneNumber( each );
+                recipientsList.add( user );
+            }
+            
             //message = messageSender.sendMessage( smsSubject, smsMessage, currentUser, true, recipients, gatewayId );
             message = messageSender.sendMessage( smsSubject, smsMessage, currentUser, recipientsList, false );
 
@@ -282,26 +267,11 @@
             Patient patient = null;
             //Set<String> phones = new HashSet<String>();
 
-            try
-            {
-                ObjectMapper mapper = new ObjectMapper().setVisibility( PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY );
-                mapper.disable( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES );
-
-                recipients = mapper.readValue( recipients.iterator().next(), Set.class );
-            }
-            catch ( JsonParseException e )
-            {
-                e.printStackTrace();
-            }
-            catch ( JsonMappingException e )
-            {
-                e.printStackTrace();
-            }
-            catch ( IOException e )
-            {
-                e.printStackTrace();
-            }
-
+            ObjectMapper mapper = new ObjectMapper().setVisibility( PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY );
+            mapper.disable( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES );
+
+            recipients = mapper.readValue( recipients.iterator().next(), Set.class );
+            
             for ( String patientId : recipients )
             {
                 patient = patientService.getPatient( Integer.parseInt( patientId ) );